import { Point, Curve } from "./Point"; import { FullProofOfExponent } from "./FullProofOfExponent"; import { UsageProofOfExponent } from "./UsageProofOfExponent"; import { ProofOfExponentInterface } from "./ProofOfExponentInterface"; export declare const Pedestren_G: Point; export declare const Pedestren_H: Point; export declare class AttestationCrypto { rand: bigint; static OID_SIGNATURE_ALG: string; static BYTES_IN_DIGEST: number; static fieldSize: bigint; static curveOrder: bigint; private curveOrderBitLength; static cofactor: bigint; static curve: Curve; static G: Point; static H: Point; constructor(); private verifyCurveOrder; getType(type: string): number; /** * Construct a Pedersen commitment to an identifier using a specific secret. * @param identifier The common identifier * @param type The type of identifier * @param secret The secret randomness to be used in the commitment * @return */ makeCommitment(identifier: string, type: number, secret: bigint): Uint8Array; /** * Constructs a commitment to an identifier based on hidden randomization supplied from a user. * This is used to construct an attestation. * @param identifier The user's identifier. * @param type The type of identifier. * @param hiding The hiding the user has picked * @return */ makeCommitmentFromHiding(identifier: string, type: number, hiding: Point): Uint8Array; injectIdentifierType(type: number, arr: Uint8Array): Uint8Array; mapToInteger(arr: Uint8Array): bigint; mapToCurveMultiplier(type: number, identifier: string): bigint; computePoint_bn256(x: bigint): Point; makeSecret(bytes?: number): bigint; static generateRandomHexString(len: number): string; /** * Computes a proof of knowledge of a random exponent * This is used to convince the attestor that the user knows a secret which the attestor will * then use to construct a Pedersen commitment to the user's identifier. * @param randomness The randomness used in the commitment * @return */ computeAttestationProof(randomness: bigint, nonce?: Uint8Array): FullProofOfExponent; /** * Compute a proof that commitment1 and commitment2 are Pedersen commitments to the same message and that the user * knows randomness1-randomness2. * NOTE: We are actually not proving that the user knows the message and randomness1 and randomness2. * This is because we assume the user has already proven knowledge of his message (mail) and the * randomness1 used in the attestation to the attestor. Because of this assumption it is enough to prove * knowledge of randomness2 (equivalent to proving knowledge of randomness1-randomness2) and that the * commitments are to the same message. * The reason we do this is that this weaker proof is significantly cheaper to execute on the blockchain. * * In conclusion what this method actually proves is knowledge that randomness1-randomness2 is the * discrete log of commitment1/commitment2. * I.e. that commitment1/commitment2 =H^(randomness1-randomness2) * @param commitment1 First Pedersen commitment to some message m * @param commitment2 Second Pedersen commitment to some message m * @param randomness1 The randomness used in commitment1 * @param randomness2 The randomness used in commitment2 * @return */ computeEqualityProof(commitment1: string, commitment2: string, randomness1: bigint, randomness2: bigint, nonce?: Uint8Array): UsageProofOfExponent; /** * Constructs a Schnorr proof of knowledge of exponent of a riddle to base H. * The challenge value used (c) is computed from the challengeList and the internal t value. * The method uses rejection sampling to ensure that the t value is sampled s.t. the * challenge will always be less than curveOrder. */ private constructSchnorrPOK; computeChallenge(t: Point, challengeList: Point[], nonce: Uint8Array): bigint; /** * Verifies a zero knowledge proof of knowledge of a riddle used in an attestation request * @param pok The proof to verify * @return True if the proof is OK and false otherwise */ verifyFullProof(pok: FullProofOfExponent): boolean; /** * Verifies a zero knowledge proof of knowledge of the two riddles used in two different * commitments to the same message. * This is used by the smart contract to verify that a request is ok where one commitment is the * riddle for a cheque/ticket and the other is the riddle from an attesation. * @param pok The proof to verify * @return True if the proof is OK and false otherwise */ verifyEqualityProof(commitment1: Uint8Array, commitment2: Uint8Array, pok: ProofOfExponentInterface): boolean; private verifyPok; makeArray(pointArray: Point[]): Uint8Array; static hashWithKeccak(data: Uint8Array): Uint8Array; static validatePointToCurve(point: Point, curve: Curve): boolean; }