UNPKG

mina-attestations

Version:
280 lines (279 loc) 13.1 kB
import { Bytes, EcdsaSignature, Field, type From, Provable, UInt8, Unconstrained } from 'o1js'; import { DynamicArray } from '../dynamic.ts'; export { EcdsaEthereum, parseSignature, parseAddress, recoverPublicKey, publicKeyToAddress, verifyEthereumSignature, verifyEthereumSignatureSimple, getHashHelper, }; declare const PublicKey_base: typeof import("o1js").ForeignCurve; declare class PublicKey extends PublicKey_base { } declare const Signature_base: typeof EcdsaSignature; declare class Signature extends Signature_base { } /** * Ethereum-style ECDSA signature credentials. */ declare const EcdsaEthereum: { Signature: typeof Signature; PublicKey: typeof PublicKey; MessageHash: typeof Bytes.Base; Address: typeof Bytes.Base; parseSignature: typeof parseSignature; parseAddress: typeof parseAddress; /** * Credential that wraps an Ethereum-style ECDSA signature. */ Credential({ maxMessageLength }: { maxMessageLength: number; }): Promise<Omit<{ spec: import("../credential.ts").CredentialSpec<import("../credential-imported.ts").ImportedWitness<{ signerAddress: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; }>, { message: import("../dynamic.ts").DynamicBytesBase; }>; program: { publicInputType: Provable<{ signerAddress: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; }, { signerAddress: { bytes: { value: bigint; }[]; }; }>; publicOutputType: import("../o1js-missing.ts").ProvableType<import("../credential.ts").Credential<{ message: import("../dynamic.ts").DynamicBytesBase; }>>; analyzeMethods(): Promise<Record<string, any>>; maxProofsVerified(): Promise<0 | 1 | 2>; compile: (options?: { cache?: import("o1js").Cache; forceRecompile?: boolean; proofsEnabled?: boolean; }) => Promise<{ verificationKey: import("o1js").VerificationKey; }>; run(...inputs: any): Promise<{ proof: import("o1js").Proof<{ signerAddress: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; }, import("../credential.ts").Credential<{ message: import("../dynamic.ts").DynamicBytesBase; }>>; auxiliaryOutput: undefined; }>; }; isCompiled: boolean; verificationKey: import("o1js").VerificationKey | undefined; create(...inputs: any): Promise<import("../credential-imported.ts").Imported<{ message: import("../dynamic.ts").DynamicBytesBase; }, { signerAddress: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; }>>; fromProof(proof: import("o1js").Proof<{ signerAddress: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; }, import("../credential.ts").Credential<{ message: import("../dynamic.ts").DynamicBytesBase; }>>, vk: import("o1js").VerificationKey): Promise<import("../credential-imported.ts").Imported<{ message: import("../dynamic.ts").DynamicBytesBase; }, { signerAddress: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; }>>; compile(options?: { cache?: import("o1js").Cache; forceRecompile?: boolean; proofsEnabled?: boolean; } | undefined): Promise<import("o1js").VerificationKey>; dummy({ owner, data, }: import("../credential.ts").Credential<{ message: import("../dynamic.ts").DynamicBytesBase; } | { message: Uint8Array<ArrayBufferLike>; }>): Promise<import("../credential-imported.ts").Imported<{ message: import("../dynamic.ts").DynamicBytesBase; }, { signerAddress: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; }>>; }, "create"> & { create(inputs: { publicInput: { signerAddress: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes | { bytes: { value: bigint; }[]; }; }; privateInput: { message: Uint8Array<ArrayBufferLike> | import("../dynamic.ts").DynamicBytesBase; signature: EcdsaSignature | { r: bigint; s: bigint; }; parityBit: boolean | Unconstrained<boolean>; }; owner: import("o1js").PublicKey; }): Promise<import("../credential-imported.ts").Imported<{ message: import("../dynamic.ts").DynamicBytesBase; }, { signerAddress: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; }>>; }>; compileDependencies: typeof compileDependencies; }; /** * Compile the ECDSA credential for the given message length and its ZkProgram dependencies. */ declare function compileDependencies({ maxMessageLength, proofsEnabled, }: { maxMessageLength: number; proofsEnabled?: boolean; }): Promise<void>; /** * Recursive ethereum-style signature verification. * * - The message is hashed in two steps, first a normal message hash (using Keccak) and then final EIP-191 hash. * - The public key is recovered from the message, signature and parity bit. It is shown to be correct by hashing to the signer address. * - The method returns nothing, and fails if the signature is invalid. */ declare function verifyEthereumSignature(message: DynamicArray<UInt8>, signature: Signature, signerAddress: Bytes, parityBit: Unconstrained<boolean>, maxMessageLength: number): Promise<{ message: DynamicArray<UInt8>; }>; /** * Non-recursive e2e signature verification, for benchmarking and testing and using outside circuits. * * Note: this is not provable due to the circuit limit, use the recursive version for that. */ declare function verifyEthereumSignatureSimple(message: DynamicArray<UInt8>, signature: Signature, signerAddress: Bytes, parityBit: Unconstrained<boolean>): void; declare function publicKeyToAddress(pk: From<typeof PublicKey>): import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; /** * Recover the implied public key from a message hash, signature and a parity bit. */ declare function recoverPublicKey(messageHash: Bytes | Uint8Array, signature: From<typeof EcdsaSignature>, isOdd: boolean): { x: bigint; y: bigint; infinity: false; }; /** * Input can be a hex string or a Uint8Array. */ declare function parseSignature(signature: string | Uint8Array): { signature: { r: bigint; s: bigint; }; parityBit: boolean; }; /** * Helper function to convert a hex address to the Bytes expected by the ECDSA credential. */ declare function parseAddress(address: string): Bytes; declare function getHashHelper(maxMessageLength: number): { name: string; maxProofsVerified(): Promise<0 | 1 | 2>; compile: (options?: { cache?: import("o1js").Cache; forceRecompile?: boolean; proofsEnabled?: boolean; }) => Promise<{ verificationKey: { data: string; hash: Field; }; }>; verify: (proof: import("o1js").Proof<import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }>, import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes>) => Promise<boolean>; digest: () => Promise<string>; analyzeMethods: () => Promise<{ short: { proofs: import("node_modules/o1js/dist/node/lib/proof-system/proof.js").ProofClass[]; rows: number; digest: string; gates: import("node_modules/o1js/dist/node/snarky.js").Gate[]; publicInputSize: number; print(): void; summary(): Partial<Record<import("node_modules/o1js/dist/node/snarky.js").GateType | "Total rows", number>>; }; }>; publicInputType: Omit<import("o1js").ProvableHashable<import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }>, { value: bigint; }[]>, "fromValue"> & { fromValue: (value: import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }> | (UInt8 | { value: bigint; })[]) => import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }>; } & Omit<import("o1js").ProvablePure<import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }>, { value: bigint; }[]>, "fromValue">; publicOutputType: import("node_modules/o1js/dist/node/lib/provable/types/struct.js").ProvablePureExtended<import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes, { bytes: { value: bigint; }[]; }, { bytes: { value: string; }[]; }>; privateInputTypes: { short: []; }; auxiliaryOutputTypes: { short: undefined; }; rawMethods: { short: (publicInput: import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }>) => Promise<{ publicOutput: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; }>; }; Proof: { new ({ proof, publicInput, publicOutput, maxProofsVerified, }: { proof: import("node_modules/o1js/dist/node/snarky.js").Pickles.Proof; publicInput: import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }>; publicOutput: import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes; maxProofsVerified: 0 | 1 | 2; }): import("o1js").Proof<import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }>, import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes>; fromJSON<S extends import("node_modules/o1js/dist/node/lib/util/types.js").Subclass<typeof import("o1js").Proof>>(this: S, { maxProofsVerified, proof: proofString, publicInput: publicInputJson, publicOutput: publicOutputJson, }: import("o1js").JsonProof): Promise<import("o1js").Proof<import("o1js").InferProvable<S["publicInputType"]>, import("o1js").InferProvable<S["publicOutputType"]>>>; dummy<Input, OutPut>(publicInput: Input, publicOutput: OutPut, maxProofsVerified: 0 | 1 | 2, domainLog2?: number): Promise<import("o1js").Proof<Input, OutPut>>; readonly provable: { toFields: (value: import("o1js").Proof<any, any>) => import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]; toAuxiliary: (value?: import("o1js").Proof<any, any> | undefined) => any[]; fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[], aux: any[]) => import("o1js").Proof<any, any>; sizeInFields(): number; check: (value: import("o1js").Proof<any, any>) => void; toValue: (x: import("o1js").Proof<any, any>) => import("node_modules/o1js/dist/node/lib/proof-system/proof.js").ProofValue<any, any>; fromValue: (x: import("node_modules/o1js/dist/node/lib/proof-system/proof.js").ProofValue<any, any> | import("o1js").Proof<any, any>) => import("o1js").Proof<any, any>; toCanonical?: ((x: import("o1js").Proof<any, any>) => import("o1js").Proof<any, any>) | undefined; }; publicInputType: import("o1js").FlexibleProvable<any>; publicOutputType: import("o1js").FlexibleProvable<any>; tag: () => { name: string; }; publicFields(value: import("o1js").ProofBase): { input: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]; output: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]; }; _proofFromBase64(proofString: import("node_modules/o1js/dist/node/snarky.js").Base64ProofString, maxProofsVerified: 0 | 1 | 2): unknown; _proofToBase64(proof: import("node_modules/o1js/dist/node/snarky.js").Pickles.Proof, maxProofsVerified: 0 | 1 | 2): string; }; proofsEnabled: boolean; setProofsEnabled(proofsEnabled: boolean): void; } & { short: (publicInput: import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }> | (UInt8 | { value: bigint; })[]) => Promise<{ proof: import("o1js").Proof<import("../dynamic/dynamic-array.ts").DynamicArrayBase<UInt8, { value: bigint; }>, import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes>; auxiliaryOutput: undefined; }>; };