UNPKG

mina-attestations

Version:
46 lines (45 loc) 1.45 kB
/** * RSA signature verification with o1js * * This is copied and modified from an example in the o1js repo: https://github.com/o1-labs/o1js/tree/main/src/examples/crypto/rsa */ import { Bytes, Field, Unconstrained } from 'o1js'; export { Bigint2048, rsaVerify65537, rsaSign }; declare class Bigint2048 { fields: Field[]; value: Unconstrained<bigint>; constructor(props: { fields: Field[]; value: Unconstrained<bigint>; }); modMul(x: Bigint2048, y: Bigint2048): Bigint2048; modSquare(x: Bigint2048): Bigint2048; toBigint(): bigint; static from(x: bigint | Bigint2048): Bigint2048; static unsafeFromLimbs(fields: Field[]): Bigint2048; static provable: import("o1js").ProvableHashable<Bigint2048, bigint>; } /** * RSA signature verification, * assuming a public exponent of e = 65537 * * Scheme: RSASSA-PKCS1-v1.5 * * Spec: * https://datatracker.ietf.org/doc/html/rfc3447#section-8.2 */ declare function rsaVerify65537(message: Bytes, signature: Bigint2048, modulus: Bigint2048): void; /** * Generates an RSA signature for the given message using the private key d and modulus n, * according to RSASSA-PKCS1-v1.5 * * Returns the signature as a bigint. * * Notes: * - Expects an already hashed input, rather than performing the sha256 hash itself * - This method is not provable! */ declare function rsaSign(message: Bytes, keys: { d: bigint; n: bigint; }): bigint;