Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,577 changes: 1,264 additions & 313 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ members = [
"basics/transfer-sol/anchor/programs/*",
"basics/transfer-sol/asm",

# cryptography
"cryptography/bls12-381/pinocchio/program",
"cryptography/bn254/pinocchio/program",

# tokens
"tokens/create-token/native/program",
"tokens/create-token/pinocchio/program",
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,22 @@ Work with Metaplex compressed NFTs.

[anchor](./compression/cutils/anchor)

## Cryptography

One stateless program per curve, wrapping the raw cryptographic syscalls. These run in LiteSVM today but only work on public clusters once their feature gates activate. Applied examples (multisig, key registry, encrypted ballot) live in the [crypto-primitives-examples](https://github.com/solana-foundation/crypto-primitives-examples) reference repo.

### BN254 (alt_bn128) operations

Add and scalar-multiply G2 points (SIMD-0302) and verify aggregate BLS signatures with a single pairing check, via the `sol_alt_bn128_group_op` syscall.

[pinocchio](./cryptography/bn254/pinocchio)

### BLS12-381 curve operations

Add, subtract, and scalar-multiply BLS12-381 G1 and G2 points with the `sol_curve_group_op` syscall.

[pinocchio](./cryptography/bls12-381/pinocchio)

## Oracles

### pyth
Expand Down
22 changes: 22 additions & 0 deletions cryptography/bls12-381/pinocchio/README.md
Comment thread
dev-jodee marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# BLS12-381 curve operations (Pinocchio)

A stateless program that wraps the BLS12-381 group operations of the `sol_curve_group_op` syscall. Results come back as transaction return data. Points are big-endian: G1 = 96 bytes, G2 = 192 bytes; scalars are 32 bytes big-endian and go first in the instruction data.

| Discriminator | Instruction | Input |
| ------------- | ----------- | -------------- |
| 0 | G1 add | point ‖ point |
| 1 | G1 sub | point ‖ point |
| 2 | G1 mul | scalar ‖ point |
| 3 | G2 add | point ‖ point |
| 4 | G2 sub | point ‖ point |
| 5 | G2 mul | scalar ‖ point |

The syscall runs in LiteSVM today but only works on public clusters once the `enable_bls12_381_syscall` feature gate activates.

## Test

```sh
pnpm install
pnpm build-and-test # TypeScript tests (mocha + LiteSVM)
cargo test --manifest-path=./program/Cargo.toml # Rust tests (litesvm), after build-and-test
```
24 changes: 24 additions & 0 deletions cryptography/bls12-381/pinocchio/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "bls12-381-pinocchio",
"version": "0.1.0",
"type": "module",
"scripts": {
"test": "mocha --import=tsx -t 1000000 ./tests/bls12-381.test.ts",
"build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test",
"build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so",
"deploy": "solana program deploy ./program/target/so/bls12_381_pinocchio_program.so"
},
"dependencies": {
"@solana/kit": "^7.0.0"
},
"devDependencies": {
"@types/chai": "^5.2.3",
"@types/mocha": "^10.0.10",
"@types/node": "^26.1.0",
"chai": "^6.2.2",
"litesvm": "^1.3.0",
"mocha": "^11.7.5",
"tsx": "^4.19.2",
"typescript": "^5.9.3"
}
}
Loading
Loading