Poseidon
const Poseidon: {
"Sponge": typeof Sponge;
"Unsafe": {
"hashToGroup": Group;
};
"hash": Field;
"hashPacked": Field;
"hashToGroup": Group;
"hashWithPrefix": Field;
"initialState": [Field, Field, Field];
"update": [Field, Field, Field];
};
Type declaration
Sponge
Sponge: typeof Sponge;
Unsafe
Unsafe: {
"hashToGroup": Group;
};
Unsafe.hashToGroup()
Low-level version of Poseidon.hashToGroup().
Warning: This function is marked unsafe because its output is not deterministic. It returns the square root of a value without constraining which of the two possible square roots is chosen. This allows the prover to choose between two different hashes, which can be a vulnerability if consuming code treats the output as unique.
Parameters
• input: Field[]
Returns
hash()
Parameters
• input: Field[]
Returns
hashPacked()
Hashes a provable type efficiently.
let skHash = Poseidon.hashPacked(PrivateKey, secretKey);
Note: Instead of just doing Poseidon.hash(value.toFields()), this
uses the toInput() method on the provable type to pack the input into as few
field elements as possible. This saves constraints because packing has a much
lower per-field element cost than hashing.
Type parameters
• T
Parameters
• type: Hashable\<T>
• value: T
Returns
hashToGroup()
Hashes a list of field elements to a point on the Pallas curve.
The output point is deterministic and its discrete log is not efficiently computable.
Parameters
• input: Field[]
Returns
hashWithPrefix()
Parameters
• prefix: string
• input: Field[]
Returns
initialState()
Returns
update()
Parameters
• state: [Field, Field, Field]
• input: Field[]