Skip to content
Open
Changes from all 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
18 changes: 9 additions & 9 deletions core/cap-0075.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Two new functions with export names `p` and `q` in the crypto module (`c`) are a
"name": "poseidon_permutation",
"args": [
{ "name": "input", "type": "VecObject" },
{ "name": "field", "type": "U32Val" },
{ "name": "field", "type": "Symbol" },
{ "name": "t", "type": "U32Val" },
{ "name": "d", "type": "U32Val" },
{ "name": "rounds_f", "type": "U32Val" },
Expand All @@ -58,15 +58,15 @@ Two new functions with export names `p` and `q` in the crypto module (`c`) are a
{ "name": "round_constants", "type": "VecObject" }
],
"return": "VecObject",
"docs": "Performs Poseidon permutation on input vector. input: vector of field elements (length t). field: 0=BLS12-381 Fr, 1=BN254 Fr. t: state size. d: S-box degree (5 for BLS12-381/BN254). rounds_f: number of full rounds (must be even). rounds_p: number of partial rounds. mds: t-by-t MDS matrix as Vec<Vec<Scalar>>. round_constants: (rounds_f+rounds_p)-by-t round constants matrix as Vec<Vec<Scalar>>. Returns output vector after permutation.",
"docs": "Performs Poseidon permutation on input vector. `input`: vector of field elements (length `t`). `field`: `BLS12_381` or `BN254`. `t`: state size. `d`: S-box degree (5 for `BLS12_381`/`BN254`). `rounds_f`: number of full rounds (must be even). `rounds_p`: number of partial rounds. `mds`: `t`-by-`t` MDS matrix as `Vec<Vec<Scalar>>`. `round_constants`: (`rounds_f` + `rounds_p`)-by-`t` round constants matrix as `Vec<Vec<Scalar>>`. Returns output vector after permutation.",
"min_supported_protocol": 25
},
{
"export": "q",
"name": "poseidon2_permutation",
"args": [
{ "name": "input", "type": "VecObject" },
{ "name": "field", "type": "U32Val" },
{ "name": "field", "type": "Symbol" },
{ "name": "t", "type": "U32Val" },
{ "name": "d", "type": "U32Val" },
{ "name": "rounds_f", "type": "U32Val" },
Expand All @@ -75,7 +75,7 @@ Two new functions with export names `p` and `q` in the crypto module (`c`) are a
{ "name": "round_constants", "type": "VecObject" }
],
"return": "VecObject",
"docs": "Performs Poseidon2 permutation on input vector. input: vector of field elements (length t). field: 0=BLS12-381 Fr, 1=BN254 Fr. t: state size. d: S-box degree (3, 5, 7, or 11). rounds_f: number of full rounds (must be even). rounds_p: number of partial rounds. mat_internal_diag_m_1: internal matrix diagonal minus 1 as Vec<Scalar> (length t). round_constants: (rounds_f+rounds_p)-by-t round constants matrix as Vec<Vec<Scalar>>. Returns output vector after permutation.",
"docs": "Performs Poseidon2 permutation on input vector. `input`: vector of field elements (length `t`). `field`: `BLS12_381` or `BN254`. `t`: state size. `d`: S-box degree (3, 5, 7, or 11). `rounds_f`: number of full rounds (must be even). `rounds_p`: number of partial rounds. `mat_internal_diag_m_1`: internal matrix diagonal minus 1 as `Vec<Scalar>` (length `t`). `round_constants`: (`rounds_f` + `rounds_p`)-by-`t` round constants matrix as `Vec<Vec<Scalar>>`. Returns output vector after permutation.",
"min_supported_protocol": 25
}
```
Expand Down Expand Up @@ -109,9 +109,9 @@ diff --git a/Stellar-contract-config-setting.x b/Stellar-contract-config-setting

#### Field Selection

The `field` parameter specifies the scalar field:
- `0`: BLS12-381 Fr (scalar field order r = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001)
- `1`: BN254 Fr (scalar field order r = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001)
The `field` parameter is a `Symbol` that selects the scalar field:
- `BLS12_381`: BLS12-381 Fr (scalar field order `r` = `0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001`)
- `BN254`: BN254 Fr (scalar field order `r` = `0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001`)

Scalar field elements are represented as `U256Val` objects as specified in CAP-0059.

Expand Down Expand Up @@ -156,7 +156,7 @@ The host function will trap if:
- `mds` matrix is not `t` by `t` (Poseidon only)
- `mat_internal_diag_m_1` vector length does not equal `t` (Poseidon2 only)
- `round_constants` matrix dimensions are not `(rounds_f + rounds_p)` by `t`
- `field` parameter is not 0 or 1
- `field` is neither `BLS12_381` nor `BN254`

#### Cost Metering

Expand Down Expand Up @@ -223,7 +223,7 @@ Common parameter sets have been published by the Poseidon authors and adopted by

### Backwards Incompatibilities

This CAP does not introduce backward incompatibilities. The new host functions are only available in protocol version 24 and later.
This CAP does not introduce backward incompatibilities. The new host functions are only available in Protocol 25 and later.

## Security Concerns

Expand Down
Loading