@zkpersona/noir-ring-signatures
Version:
Implementation of Ring Signatures in Noir
67 lines (63 loc) • 2.9 kB
text/typescript
import * as _aztec_aztec_js from '@aztec/aztec.js';
import { GrumpkinScalar, Point } from '@aztec/aztec.js';
import { Fieldable } from '@aztec/foundation/serialize';
/**
* Computes the modulo operation on a bigint value with a specified modulus.
* Ensures the result is always non-negative and within the range [0, modulus).
*
* @param value - The value to compute modulo on
* @param modulus - The modulus to use (defaults to GrumpkinScalar.MODULUS)
* @returns The result of value mod modulus, guaranteed to be non-negative
*/
declare const mod: (value: bigint, modulus?: bigint) => bigint;
/**
* Generates a random scalar value on the Grumpkin curve.
* This is useful for creating private keys and random values in cryptographic operations.
*
* @returns A random GrumpkinScalar value
*/
declare const randomScalar: () => _aztec_aztec_js.Fq;
/**
* Generates a new key pair for the Grumpkin curve.
* The key pair consists of a private key (scalar) and its corresponding public key (point).
*
* @returns A Promise that resolves to an object containing:
* - privateKey: A random GrumpkinScalar value
* - publicKey: The corresponding public key point on the Grumpkin curve
*/
declare const generateKeyPair: () => Promise<{
privateKey: _aztec_aztec_js.Fq;
publicKey: _aztec_aztec_js.Point;
}>;
/**
* Hashes an array of field elements to a scalar value on the Grumpkin curve.
* This is useful for converting arbitrary data into a scalar value for cryptographic operations.
*
* @param input - An array of field elements to hash
* @returns A Promise that resolves to a GrumpkinScalar value
*/
declare const hashToScalar: (input: Fieldable[]) => Promise<GrumpkinScalar>;
/**
* Represents a SAG (Signature of Anonymous Group) ring signature.
*
* A ring signature allows a member of a group to sign a message on behalf of the group
* without revealing which member actually created the signature. This provides
* anonymity for the signer while still proving that the signature came from a member
* of the specified group.
*
* @property c0 - The initial challenge value in the signature scheme. This is a scalar
* value on the Grumpkin curve that serves as the starting point for
* the verification process.
* @property s - Array of response values for each ring member. Each value is a scalar
* on the Grumpkin curve that proves knowledge of the corresponding
* private key without revealing which one it is.
* @property publicKeys - Array of public keys forming the ring. These are points on
* the Grumpkin curve that represent the possible signers of the
* message.
*/
interface RingSignature {
c0: GrumpkinScalar;
s: GrumpkinScalar[];
publicKeys: Point[];
}
export { type RingSignature, generateKeyPair, hashToScalar, mod, randomScalar };