UNPKG

@aptos-labs/ts-sdk

Version:
127 lines 6.1 kB
import { AptosConfig } from "../api/aptosConfig.js"; import { AccountAddressInput } from "../core/accountAddress.js"; import { MoveJWK, ZeroKnowledgeSig } from "../core/crypto/keyless.js"; import { HexInput } from "../types/index.js"; import { Account } from "../account/index.js"; import { EphemeralKeyPair } from "../account/EphemeralKeyPair.js"; import { KeylessAccount } from "../account/KeylessAccount.js"; import { ProofFetchCallback } from "../account/AbstractKeylessAccount.js"; import { FederatedKeylessAccount } from "../account/FederatedKeylessAccount.js"; import { InputGenerateTransactionOptions, SimpleTransaction } from "../transactions/index.js"; /** * Retrieves a pepper value based on the provided configuration and authentication details. * * @param args - The arguments required to fetch the pepper. * @param args.aptosConfig - The configuration object for Aptos. * @param args.jwt - The JSON Web Token used for authentication. * @param args.ephemeralKeyPair - The ephemeral key pair used for the operation. * @param args.uidKey - An optional unique identifier key (defaults to "sub"). * @param args.derivationPath - An optional derivation path for the key. * @returns A Uint8Array containing the fetched pepper value. * @group Implementation */ export declare function getPepper(args: { aptosConfig: AptosConfig; jwt: string; ephemeralKeyPair: EphemeralKeyPair; uidKey?: string; derivationPath?: string; }): Promise<Uint8Array>; /** * Retrieves the `pepper_base` for an account — the VUF signature from which the final pepper is derived. * * Unlike {@link getPepper} (which hits the pepper service `fetch` endpoint and returns the 31-byte derived * pepper), this hits the `signature` endpoint and returns the raw 48-byte `pepper_base` (a compressed * BLS12-381 G1 point). `pepper_base` is deterministic for a given OIDC identity, independent of the ephemeral * key and of the derivation path, which makes it a stable seed for deriving a confidential-asset decryption * key (see `@aptos-labs/confidential-asset`'s `TwistedEd25519PrivateKey.fromPepperBase`). Deriving secrets * from `pepper_base` rather than the final pepper also ensures a leaked pepper does not compromise them. * * @param args - The arguments required to fetch the pepper base. * @param args.aptosConfig - The configuration object for Aptos. * @param args.jwt - The JSON Web Token used for authentication. * @param args.ephemeralKeyPair - The ephemeral key pair used for the operation. * @param args.uidKey - An optional unique identifier key (defaults to "sub"). * @param args.derivationPath - An optional derivation path for the key. * @returns A Uint8Array containing the 48-byte `pepper_base`. * @group Implementation */ export declare function getPepperBase(args: { aptosConfig: AptosConfig; jwt: string; ephemeralKeyPair: EphemeralKeyPair; uidKey?: string; derivationPath?: string; }): Promise<Uint8Array>; /** * Generates a zero-knowledge proof based on the provided parameters. * This function is essential for creating a signed proof that can be used in various cryptographic operations. * * @param args - The parameters required to generate the proof. * @param args.aptosConfig - The configuration settings for Aptos. * @param args.jwt - The JSON Web Token used for authentication. * @param args.ephemeralKeyPair - The ephemeral key pair used for generating the proof. * @param args.pepper - An optional hex input used to enhance security (default is generated if not provided). * @param args.uidKey - An optional string that specifies the unique identifier key (defaults to "sub"). * @throws Error if the pepper length is not valid or if the ephemeral key pair's lifespan exceeds the maximum allowed. * @group Implementation */ export declare function getProof(args: { aptosConfig: AptosConfig; jwt: string; ephemeralKeyPair: EphemeralKeyPair; pepper?: HexInput; uidKey?: string; maxExpHorizonSecs?: number; }): Promise<ZeroKnowledgeSig>; /** * Derives a keyless account by fetching the necessary proof and looking up the original account address. * This function helps in creating a keyless account that can be used without managing private keys directly. * * @param args - The arguments required to derive the keyless account. * @param args.aptosConfig - The configuration settings for Aptos. * @param args.jwt - The JSON Web Token used for authentication. * @param args.ephemeralKeyPair - The ephemeral key pair used for cryptographic operations. * @param args.uidKey - An optional unique identifier key for the user. * @param args.pepper - An optional hexadecimal input used for additional security. * @param args.proofFetchCallback - An optional callback function to handle the proof fetch outcome. * @returns A keyless account object. * @group Implementation */ export declare function deriveKeylessAccount(args: { aptosConfig: AptosConfig; jwt: string; ephemeralKeyPair: EphemeralKeyPair; uidKey?: string; pepper?: HexInput; proofFetchCallback?: ProofFetchCallback; }): Promise<KeylessAccount>; export declare function deriveKeylessAccount(args: { aptosConfig: AptosConfig; jwt: string; ephemeralKeyPair: EphemeralKeyPair; jwkAddress: AccountAddressInput; uidKey?: string; pepper?: HexInput; proofFetchCallback?: ProofFetchCallback; }): Promise<FederatedKeylessAccount>; export declare function deriveKeylessAccount(args: { aptosConfig: AptosConfig; jwt: string; ephemeralKeyPair: EphemeralKeyPair; jwkAddress?: AccountAddressInput; uidKey?: string; pepper?: HexInput; proofFetchCallback?: ProofFetchCallback; }): Promise<KeylessAccount | FederatedKeylessAccount>; export interface JWKS { keys: MoveJWK[]; } export declare function updateFederatedKeylessJwkSetTransaction(args: { aptosConfig: AptosConfig; sender: Account; iss: string; jwksUrl?: string; options?: InputGenerateTransactionOptions; }): Promise<SimpleTransaction>; //# sourceMappingURL=keyless.d.ts.map