UNPKG

mina-attestations

Version:
48 lines (47 loc) 1.79 kB
import { Field, PublicKey } from 'o1js'; import type { ContextJSON } from './validation.ts'; export { computeHttpsContext, computeZkAppContext, hashContext, serializeInputContext, deserializeHttpsContext, deserializeZkAppContext, type ZkAppIdentity, type NetworkId, type ZkAppInputContext, type ZkAppContext, type HttpsInputContext, type HttpsWalletContext, type HttpsContext, type WalletDerivedContext, }; type ContextType = 'zk-app' | 'https'; type BaseInputContext = { action: string; serverNonce: Field; }; type HttpsInputContext = BaseInputContext & { type: 'https'; }; type NetworkId = 'mainnet' | 'devnet' | { custom: string; }; type ZkAppIdentity = { publicKey: PublicKey; tokenId: Field; network: NetworkId; }; type ZkAppInputContext = BaseInputContext & { type: 'zk-app'; verifierIdentity: ZkAppIdentity; }; type HttpsWalletContext = { verifierIdentity: string; }; type WalletDerivedContext = { vkHash: Field; claims: Field; clientNonce: Field; }; type ZkAppContext = ZkAppInputContext & WalletDerivedContext; type HttpsContext = HttpsInputContext & HttpsWalletContext & WalletDerivedContext; type ContextOutput = { type: ContextType; vkHash: Field; nonce: Field; verifierIdentity: Field; action: Field; claims: Field; }; declare function computeHttpsContext(input: HttpsContext): ContextOutput; declare function computeZkAppContext(input: ZkAppContext): ContextOutput; declare function hashContext(input: ContextOutput): Field; declare function serializeInputContext(context: undefined | ZkAppInputContext | HttpsInputContext): ContextJSON; declare function deserializeHttpsContext(context: ContextJSON): HttpsInputContext; declare function deserializeZkAppContext(context: ContextJSON): ZkAppInputContext;