diff --git a/.eslintrc b/.eslintrc index a3e921d2c..b2e73e59a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,6 +13,8 @@ "webpack", "scripts", "tests", + "demos", + "anoncreds-rust", "didcomm-rust" ], "plugins": ["@typescript-eslint", "react"], @@ -29,6 +31,7 @@ "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-namespace": "off", "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": ["warn"] }, diff --git a/.vscode/launch.json b/.vscode/launch.json index 0ea1a185b..0dc0282af 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,10 +3,11 @@ "configurations": [ { "name": "NODE DEBUG", - "program": "${workspaceFolder}/build/node-test/index.js", + "program": "${workspaceFolder}/.mock/dist/.mock/src/index.js", "request": "launch", "skipFiles": ["/**"], - "type": "node" + "type": "node", + "cwd": "${workspaceFolder}/.mock" }, { "type": "node", diff --git a/README.md b/README.md index 3ad8208b1..22e5fae5e 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,13 @@ This repository includes a browser and a Node.js demo application, and also a st To be able to run the demos, we have to build `prism-wallet-sdk-ts`. -create an .npmrc file with the following contents: +In order to install the package you must have created a github token with access to github repository packages and create a .npmrc file with the follwing content (assumming): ``` +//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} @input-output-hk:registry=https://npm.pkg.github.com ``` - From the repository root run: diff --git a/anoncreds-rust/browser/LICENSE b/anoncreds-rust/browser/LICENSE new file mode 100644 index 000000000..11153de76 --- /dev/null +++ b/anoncreds-rust/browser/LICENSE @@ -0,0 +1,192 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2017 Sovrin Foundation + Copyright 2020 Province of British Columbia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/anoncreds-rust/browser/README.md b/anoncreds-rust/browser/README.md new file mode 100644 index 000000000..7281f5261 --- /dev/null +++ b/anoncreds-rust/browser/README.md @@ -0,0 +1,77 @@ +# anoncreds-rs + +Rust library and reference implementation of the [Anoncreds V1.0 +specification](https://hyperledger.github.io/anoncreds-spec/). + +The AnonCreds (Anonymous Credentials) specification is based on the open source +verifiable credential implementation of AnonCreds that has been in use since +2017, initially as part of the Hyperledger Indy open source project and now in +the Hyperledger AnonCreds project. The extensive use of AnonCreds around the +world has made it a de facto standard for ZKP-based verifiable credentials, and +this specification is the formalization of that implementation. + +## Library + +Anoncreds-rs exposes three main parts: [`issuer`](./src/services/issuer.rs), +[`prover`](./src/services/prover.rs) and +[`verifier`](./src/services/verifier.rs). + +### Issuer + +- Create a [schema](https://hyperledger.github.io/anoncreds-spec/#schema-publisher-publish-schema-object) +- Create a [credential definition](https://hyperledger.github.io/anoncreds-spec/#issuer-create-and-publish-credential-definition-object) +- Create a [revocation registry definition](https://hyperledger.github.io/anoncreds-spec/#issuer-create-and-publish-revocation-registry-objects) +- Create a [revocation status list](https://hyperledger.github.io/anoncreds-spec/#publishing-the-initial-initial-revocation-status-list-object) +- Update a [revocation status list](https://hyperledger.github.io/anoncreds-spec/#publishing-the-initial-initial-revocation-status-list-object) +- Update a [revocation status list](https://hyperledger.github.io/anoncreds-spec/#publishing-the-initial-initial-revocation-status-list-object)'s timestamp +- Create a [credential offer](https://hyperledger.github.io/anoncreds-spec/#credential-offer) +- Create a [credential](https://hyperledger.github.io/anoncreds-spec/#issue-credential) + +### Prover / Holder + +- Create a [credential request](https://hyperledger.github.io/anoncreds-spec/#credential-request) +- Process an incoming [credential](https://hyperledger.github.io/anoncreds-spec/#receiving-a-credential) +- Create a [presentation](https://hyperledger.github.io/anoncreds-spec/#generate-presentation) +- Create, and update, a revocation state +- Create, and update, a revocation state with a witness + +### Verifier + +- [Verify a presentation](https://hyperledger.github.io/anoncreds-spec/#verify-presentation) +- generate a nonce + +## Wrappers + +Anoncreds is, soon, available as a standalone library in Rust, but also via wrappers. + +| Language | Directory | Status | +| ------------ | --------------------------------------------------------------------------------------- | ------ | +| Node.js | [javascript](https://github.com/hyperledger/anoncreds-rs/tree/main/wrappers/javascript) | ✅ | +| React Native | [javascript](https://github.com/hyperledger/anoncreds-rs/tree/main/wrappers/javascript) | ✅ | +| Python | [python](https://github.com/hyperledger/anoncreds-rs/tree/main/wrappers/python) | 🚧 | + + +## Credit + +The initial implementation of `anoncreds-rs` is derived from `indy-shared-rs` +that was developed by the Verifiable Organizations Network (VON) team based at +the Province of British Columbia, and derives largely from the implementations +within [Hyperledger Indy-SDK](https://github.com/hyperledger/indy-sdk). To +learn more about VON and what's happening with decentralized identity in +British Columbia, please go to [https://vonx.io](https://vonx.io). + +## Contributing + +Pull requests are welcome! Please read our [contributions +guide](https://github.com/hyperledger/anoncreds-rs/blob/main/CONTRIBUTING.md) +and submit your PRs. We enforce [developer certificate of +origin](https://developercertificate.org/) (DCO) commit signing. See guidance +[here](https://github.com/apps/dco). + +We also welcome issues submitted about problems you encounter in using +`anoncreds-rs` or any of the wrappers. + +## License + +[Apache License Version +2.0](https://github.com/hyperledger/anoncreds-rs/blob/main/LICENSE) diff --git a/anoncreds-rust/browser/anoncreds.d.ts b/anoncreds-rust/browser/anoncreds.d.ts new file mode 100644 index 000000000..ebf61c0ce --- /dev/null +++ b/anoncreds-rust/browser/anoncreds.d.ts @@ -0,0 +1,1014 @@ +/* tslint:disable */ +/* eslint-disable */ +/** +* @returns {number} +*/ +export function anoncredsSetDefaultLogger(): number; +/** +* @param {string} name +* @param {string} version +* @param {string} issuer_id +* @param {any[]} attribute_names +* @returns {any} +*/ +export function anoncredsCreateSchema(name: string, version: string, issuer_id: string, attribute_names: any[]): any; +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @param {string} signature_type +* @param {boolean} support_revocation +* @returns {any[]} +*/ +export function anoncredsCreateCredentialDefinition(schema_id: string, schema: any, tag: string, issuer_id: string, signature_type: string, support_revocation: boolean): any[]; +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @returns {any[]} +*/ +export function anoncredsCreateCredentialDefinitionCustom(schema_id: string, schema: any, tag: string, issuer_id: string): any[]; +/** +* @param {any} json +* @returns {boolean} +*/ +export function anoncredsValidateCredentialDefinitionFromJson(json: any): boolean; +/** +* @returns {string} +*/ +export function proverCreateLinkSecret(): string; +/** +* @param {any} cred_offer +* @param {any} cred_def +* @param {string} link_secret +* @param {string} link_secret_id +* @returns {any[]} +*/ +export function proverCreateCredentialRequest(cred_offer: any, cred_def: any, link_secret: string, link_secret_id: string): any[]; +/** +* @param {any} cred_def +* @param {any} credential +* @param {any} cred_req_meta +* @param {string} link_secret +* @returns {any} +*/ +export function proverProcessCredential(cred_def: any, credential: any, cred_req_meta: any, link_secret: string): any; +/** +* @param {any} presentation_request +* @param {any} schema_dict +* @param {any} cred_def_dict +* @param {any} credential +* @param {string} link_secret +* @returns {any} +*/ +export function proverCreatePresentation(presentation_request: any, schema_dict: any, cred_def_dict: any, credential: any, link_secret: string): any; +/** +* @returns {any} +*/ +export function issuerCreateSchema(): any; +/** +* @param {any} jsSchema +* @returns {any[]} +*/ +export function issuerCreateCredentialOffer(jsSchema: any): any[]; +/** +* @param {any} jsCredOffer +* @param {any} jsCredDef +* @param {any} jsCredDefPriv +* @param {any} jsCredRequest +* @returns {any} +*/ +export function issuerCreateCredential(jsCredOffer: any, jsCredDef: any, jsCredDefPriv: any, jsCredRequest: any): any; +/** +*/ +export enum ErrorCode { + Success = 0, + Input = 1, + IOError = 2, + InvalidState = 3, + Unexpected = 4, + CredentialRevoked = 5, + InvalidUserRevocId = 6, + ProofRejected = 7, + RevocationRegistryFull = 8, +} +/** +*/ +export class BlindedCredentialSecrets { + free(): void; +} +/** +*/ +export class BlindedCredentialSecretsCorrectnessProof { + free(): void; +} +/** +*/ +export class Bls { + free(): void; +/** +*/ + constructor(); +/** +* @param {Uint8Array} message +* @param {SignKey} sign_key +* @returns {Signature} +*/ + static sign(message: Uint8Array, sign_key: SignKey): Signature; +/** +* @param {Uint8Array} message +* @param {Signature} signature +* @param {VerKey} ver_key +* @param {Generator} generator +* @returns {boolean} +*/ + static verify(message: Uint8Array, signature: Signature, ver_key: VerKey, generator: Generator): boolean; +/** +* @param {ProofOfPossession} pop +* @param {VerKey} ver_key +* @param {Generator} generator +* @returns {boolean} +*/ + static verifyProofOfPosession(pop: ProofOfPossession, ver_key: VerKey, generator: Generator): boolean; +/** +* @param {MultiSignature} multi_sig +* @param {Uint8Array} message +* @param {any[]} ver_keys +* @param {Generator} gen +* @returns {boolean} +*/ + static verifyMultiSignature(multi_sig: MultiSignature, message: Uint8Array, ver_keys: any[], gen: Generator): boolean; +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class CredentialDefinition { + free(): void; +} +/** +*/ +export class CredentialKeyCorrectnessProof { + free(): void; +} +/** +*/ +export class CredentialPrimaryPublicKey { + free(): void; +} +/** +*/ +export class CredentialPrivateKey { + free(): void; +} +/** +*/ +export class CredentialPublicKey { + free(): void; +/** +* @returns {CredentialPrimaryPublicKey} +*/ + getPrimaryKey(): CredentialPrimaryPublicKey; +/** +* @returns {any} +*/ + getRevocationKey(): any; +} +/** +*/ +export class CredentialRevocationPublicKey { + free(): void; +} +/** +*/ +export class CredentialSchema { + free(): void; +/** +*/ + constructor(); +/** +* @param {string} attribute +*/ + addAttr(attribute: string): void; +} +/** +*/ +export class CredentialSecretsBlindingFactors { + free(): void; +} +/** +*/ +export class CredentialSignature { + free(): void; +/** +* @returns {number | undefined} +*/ + extractIndex(): number | undefined; +} +/** +*/ +export class CredentialValues { + free(): void; +/** +*/ + constructor(); +/** +* @param {MasterSecret} value +*/ + addMasterSecret(value: MasterSecret): void; +/** +* @param {string} attr +* @param {string} value +*/ + addKnown(attr: string, value: string): void; +/** +* @param {string} attr +* @param {string} value +*/ + addHidden(attr: string, value: string): void; +/** +* @param {string} attr +* @param {string} value +* @param {string} blinding_factor +*/ + addCommitment(attr: string, value: string, blinding_factor: string): void; +} +/** +*/ +export class EcdhSecp256k1Sha256 { + free(): void; +/** +*/ + constructor(); +/** +* @returns {KeyPair} +*/ + keypair(): KeyPair; +/** +* @param {Uint8Array} seed +* @returns {KeyPair} +*/ + keypair_from_seed(seed: Uint8Array): KeyPair; +/** +* @param {WasmPrivateKey} sk +* @returns {WasmPublicKey} +*/ + getPublicKey(sk: WasmPrivateKey): WasmPublicKey; +/** +* @param {WasmPrivateKey} sk +* @param {WasmPublicKey} pk +* @returns {WasmSessionKey} +*/ + computeSharedSecret(sk: WasmPrivateKey, pk: WasmPublicKey): WasmSessionKey; +} +/** +*/ +export class EcdsaSecp256k1Sha256 { + free(): void; +/** +*/ + constructor(); +/** +* @returns {KeyPair} +*/ + keypair(): KeyPair; +/** +* @param {Uint8Array} seed +* @returns {KeyPair} +*/ + keypairFromSeed(seed: Uint8Array): KeyPair; +/** +* @param {WasmPrivateKey} sk +* @returns {WasmPublicKey} +*/ + getPublicKey(sk: WasmPrivateKey): WasmPublicKey; +/** +* @param {Uint8Array} message +* @param {WasmPrivateKey} sk +* @returns {Uint8Array} +*/ + sign(message: Uint8Array, sk: WasmPrivateKey): Uint8Array; +/** +* @param {Uint8Array} message +* @param {Uint8Array} signature +* @param {WasmPublicKey} pk +* @returns {boolean} +*/ + verify(message: Uint8Array, signature: Uint8Array, pk: WasmPublicKey): boolean; +/** +* @param {Uint8Array} signature +*/ + normalizeS(signature: Uint8Array): void; +/** +* @param {WasmPublicKey} pk +* @returns {WasmPublicKey} +*/ + publicKeyCompressed(pk: WasmPublicKey): WasmPublicKey; +/** +* @param {WasmPublicKey} pk +* @returns {WasmPublicKey} +*/ + publicKeyUnCompressed(pk: WasmPublicKey): WasmPublicKey; +/** +* @param {Uint8Array} bytes +* @returns {WasmPublicKey} +*/ + parseToPublicKey(bytes: Uint8Array): WasmPublicKey; +} +/** +*/ +export class Ed25519Sha512 { + free(): void; +/** +*/ + constructor(); +/** +* @param {Uint8Array} seed +* @returns {Ed25519Sha512} +*/ + static fromSeed(seed: Uint8Array): Ed25519Sha512; +/** +* @param {Uint8Array} sk +* @returns {Ed25519Sha512} +*/ + static fromPrivateKey(sk: Uint8Array): Ed25519Sha512; +/** +* @returns {Uint8Array} +*/ + getPulicKey(): Uint8Array; +/** +* @param {Uint8Array} message +* @returns {Uint8Array} +*/ + sign(message: Uint8Array): Uint8Array; +/** +* @param {Uint8Array} message +* @param {Uint8Array} signature +* @param {Uint8Array} pk +* @returns {boolean} +*/ + static verify(message: Uint8Array, signature: Uint8Array, pk: Uint8Array): boolean; +} +/** +*/ +export class Generator { + free(): void; +/** +*/ + constructor(); +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +/** +* @param {Uint8Array} bytes +* @returns {Generator} +*/ + static fromBytes(bytes: Uint8Array): Generator; +} +/** +*/ +export class IssuedCredential { + free(): void; +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class IssuedCredentialWithRevocation { + free(): void; +} +/** +*/ +export class Issuer { + free(): void; +/** +* @param {CredentialSchema} credential_schema +* @param {NonCredentialSchema} non_credential_schema +* @param {boolean} support_revocation +* @returns {CredentialDefinition} +*/ + static newCredentialDefinition(credential_schema: CredentialSchema, non_credential_schema: NonCredentialSchema, support_revocation: boolean): CredentialDefinition; +/** +* @param {string} prover_id +* @param {BlindedCredentialSecrets} blinded_credential_secrets +* @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof +* @param {Nonce} credential_nonce +* @param {Nonce} credential_issuance_nonce +* @param {CredentialValues} credential_values +* @param {CredentialPublicKey} credential_pub_key +* @param {CredentialPrivateKey} credential_priv_key +* @returns {IssuedCredential} +*/ + static signCredential(prover_id: string, blinded_credential_secrets: BlindedCredentialSecrets, blinded_credential_secrets_correctness_proof: BlindedCredentialSecretsCorrectnessProof, credential_nonce: Nonce, credential_issuance_nonce: Nonce, credential_values: CredentialValues, credential_pub_key: CredentialPublicKey, credential_priv_key: CredentialPrivateKey): IssuedCredential; +/** +* @param {string} prover_id +* @param {BlindedCredentialSecrets} blinded_credential_secrets +* @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof +* @param {Nonce} credential_nonce +* @param {Nonce} credential_issuance_nonce +* @param {CredentialValues} credential_values +* @param {CredentialPublicKey} credential_pub_key +* @param {CredentialPrivateKey} credential_priv_key +* @param {number} rev_idx +* @param {number} max_cred_num +* @param {boolean} issuance_by_default +* @param {RevocationRegistry} rev_reg +* @param {RevocationPrivateKey} rev_key_priv +* @param {SimpleTailsAccessor} rev_tails_accessor +* @returns {IssuedCredentialWithRevocation} +*/ + static signCredentialWithRevocation(prover_id: string, blinded_credential_secrets: BlindedCredentialSecrets, blinded_credential_secrets_correctness_proof: BlindedCredentialSecretsCorrectnessProof, credential_nonce: Nonce, credential_issuance_nonce: Nonce, credential_values: CredentialValues, credential_pub_key: CredentialPublicKey, credential_priv_key: CredentialPrivateKey, rev_idx: number, max_cred_num: number, issuance_by_default: boolean, rev_reg: RevocationRegistry, rev_key_priv: RevocationPrivateKey, rev_tails_accessor: SimpleTailsAccessor): IssuedCredentialWithRevocation; +} +/** +*/ +export class KeyPair { + free(): void; +} +/** +*/ +export class MasterSecret { + free(): void; +/** +*/ + constructor(); +} +/** +*/ +export class MultiSignature { + free(): void; +/** +* @param {any[]} signatures +*/ + constructor(signatures: any[]); +/** +* @param {Uint8Array} bytes +* @returns {MultiSignature} +*/ + static fromBytes(bytes: Uint8Array): MultiSignature; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class NonCredentialSchema { + free(): void; +/** +*/ + constructor(); +/** +* @param {string} attribute +*/ + addAttr(attribute: string): void; +} +/** +*/ +export class Nonce { + free(): void; +/** +*/ + constructor(); +} +/** +*/ +export class Proof { + free(): void; +} +/** +*/ +export class ProofBuilder { + free(): void; +/** +*/ + constructor(); +/** +* @param {string} attribute +*/ + addCommonAttribute(attribute: string): void; +/** +* @param {SubProofRequest} sub_proof_request +* @param {CredentialSchema} credential_schema +* @param {NonCredentialSchema} non_credential_schema +* @param {CredentialSignature} credential_signature +* @param {CredentialValues} credential_values +* @param {CredentialPublicKey} credential_pub_key +* @param {any} rev_reg +* @param {any} witness +*/ + addSubProofRequest(sub_proof_request: SubProofRequest, credential_schema: CredentialSchema, non_credential_schema: NonCredentialSchema, credential_signature: CredentialSignature, credential_values: CredentialValues, credential_pub_key: CredentialPublicKey, rev_reg: any, witness: any): void; +/** +* @param {Nonce} nonce +* @returns {Proof} +*/ + finalize(nonce: Nonce): Proof; +} +/** +*/ +export class ProofOfPossession { + free(): void; +/** +* @param {VerKey} ver_key +* @param {SignKey} sign_key +*/ + constructor(ver_key: VerKey, sign_key: SignKey); +/** +* @param {Uint8Array} bytes +* @returns {ProofOfPossession} +*/ + static fromBytes(bytes: Uint8Array): ProofOfPossession; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class ProofVerifier { + free(): void; +/** +*/ + constructor(); +/** +* @param {SubProofRequest} sub_proof_request +* @param {CredentialSchema} credential_schema +* @param {NonCredentialSchema} non_credential_schema +* @param {CredentialPublicKey} credential_pub_key +* @param {any} rev_key_pub +* @param {any} rev_reg +*/ + addSubProofRequest(sub_proof_request: SubProofRequest, credential_schema: CredentialSchema, non_credential_schema: NonCredentialSchema, credential_pub_key: CredentialPublicKey, rev_key_pub: any, rev_reg: any): void; +/** +* @param {Proof} proof +* @param {Nonce} nonce +* @returns {boolean} +*/ + verify(proof: Proof, nonce: Nonce): boolean; +} +/** +*/ +export class Prover { + free(): void; +/** +* @param {CredentialPublicKey} credential_pub_key +* @param {CredentialKeyCorrectnessProof} credential_key_correctness_proof +* @param {CredentialValues} credential_values +* @param {Nonce} credential_nonce +* @returns {ProverBlindedCredentialSecrets} +*/ + static blindedCredentialSecrets(credential_pub_key: CredentialPublicKey, credential_key_correctness_proof: CredentialKeyCorrectnessProof, credential_values: CredentialValues, credential_nonce: Nonce): ProverBlindedCredentialSecrets; +/** +* @param {IssuedCredential} issued_credential +* @param {CredentialValues} credential_values +* @param {CredentialSecretsBlindingFactors} credential_secrets_blinding_factors +* @param {CredentialPublicKey} credential_pub_key +* @param {Nonce} nonce +* @param {any} rev_key_pub +* @param {any} rev_reg +* @param {any} witness +* @returns {CredentialSignature} +*/ + static processCredentialSignature(issued_credential: IssuedCredential, credential_values: CredentialValues, credential_secrets_blinding_factors: CredentialSecretsBlindingFactors, credential_pub_key: CredentialPublicKey, nonce: Nonce, rev_key_pub: any, rev_reg: any, witness: any): CredentialSignature; +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class ProverBlindedCredentialSecrets { + free(): void; +} +/** +*/ +export class RevocationPrivateKey { + free(): void; +} +/** +*/ +export class RevocationPublicKey { + free(): void; +} +/** +*/ +export class RevocationRegistry { + free(): void; +} +/** +*/ +export class RevocationRegistryDelta { + free(): void; +/** +* @param {any} rev_reg_from +* @param {RevocationRegistry} rev_reg_to +* @param {any} issued +* @param {any} revoked +* @returns {RevocationRegistryDelta} +*/ + static fromParts(rev_reg_from: any, rev_reg_to: RevocationRegistry, issued: any, revoked: any): RevocationRegistryDelta; +/** +* @param {RevocationRegistryDelta} other_delta +*/ + merge(other_delta: RevocationRegistryDelta): void; +} +/** +*/ +export class RevocationTailsGenerator { + free(): void; +/** +* @returns {number} +*/ + count(): number; +/** +* @returns {any} +*/ + next(): any; +} +/** +*/ +export class SignKey { + free(): void; +/** +*/ + constructor(); +/** +* @param {Uint8Array} seed +* @returns {SignKey} +*/ + static fromSeed(seed: Uint8Array): SignKey; +/** +* @param {Uint8Array} bytes +* @returns {SignKey} +*/ + static fromBytes(bytes: Uint8Array): SignKey; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class Signature { + free(): void; +/** +* @param {Uint8Array} bytes +* @returns {Signature} +*/ + static fromBytes(bytes: Uint8Array): Signature; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class SignatureCorrectnessProof { + free(): void; +} +/** +*/ +export class SimpleTailsAccessor { + free(): void; +/** +* @param {RevocationTailsGenerator} rev_tails_generator +*/ + constructor(rev_tails_generator: RevocationTailsGenerator); +/** +* @param {number} tail_id +* @param {Function} accessor +*/ + accessTail(tail_id: number, accessor: Function): void; +} +/** +*/ +export class SubProofRequest { + free(): void; +/** +*/ + constructor(); +/** +* @param {string} attribute +*/ + addRevealedAttribute(attribute: string): void; +/** +* @param {string} attribute +* @param {string} p_type +* @param {number} value +*/ + addPredicate(attribute: string, p_type: string, value: number): void; +} +/** +*/ +export class Tail { + free(): void; +} +/** +*/ +export class UrsaEncryptor { + free(): void; +/** +* @param {string} cipher +* @returns {WasmCipherKey} +*/ + static new(cipher: string): WasmCipherKey; +/** +* @param {string} cipher +* @param {string} key +* @returns {WasmCipherKey} +*/ + static withKey(cipher: string, key: string): WasmCipherKey; +/** +* @param {WasmCipherKey} cipher_key +* @param {Uint8Array} aad +* @param {Uint8Array} input +* @returns {Uint8Array} +*/ + encrypt(cipher_key: WasmCipherKey, aad: Uint8Array, input: Uint8Array): Uint8Array; +/** +* @param {WasmCipherKey} cipher_key +* @param {Uint8Array} aad +* @param {Uint8Array} input +* @returns {Uint8Array} +*/ + decrypt(cipher_key: WasmCipherKey, aad: Uint8Array, input: Uint8Array): Uint8Array; +} +/** +*/ +export class VerKey { + free(): void; +/** +* @param {Generator} generator +* @param {SignKey} sign_key +*/ + constructor(generator: Generator, sign_key: SignKey); +/** +* @param {Uint8Array} bytes +* @returns {VerKey} +*/ + static fromBytes(bytes: Uint8Array): VerKey; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class WasmCipherKey { + free(): void; +} +/** +*/ +export class WasmPrivateKey { + free(): void; +} +/** +*/ +export class WasmPublicKey { + free(): void; +/** +* @param {Uint8Array} key +*/ + constructor(key: Uint8Array); +} +/** +*/ +export class WasmSessionKey { + free(): void; +} +/** +*/ +export class Witness { + free(): void; +/** +* @param {number} rev_idx +* @param {number} max_cred_num +* @param {boolean} issuance_by_default +* @param {RevocationRegistryDelta} rev_reg_delta +* @param {SimpleTailsAccessor} rev_tails_accessor +*/ + constructor(rev_idx: number, max_cred_num: number, issuance_by_default: boolean, rev_reg_delta: RevocationRegistryDelta, rev_tails_accessor: SimpleTailsAccessor); +/** +* @param {number} rev_idx +* @param {number} max_cred_num +* @param {RevocationRegistryDelta} rev_reg_delta +* @param {SimpleTailsAccessor} rev_tails_accessor +*/ + update(rev_idx: number, max_cred_num: number, rev_reg_delta: RevocationRegistryDelta, rev_tails_accessor: SimpleTailsAccessor): void; +} +/** +*/ +export class X25519Sha256 { + free(): void; +/** +*/ + constructor(); +/** +* @returns {KeyPair} +*/ + keypair(): KeyPair; +/** +* @param {Uint8Array} seed +* @returns {KeyPair} +*/ + keypair_from_seed(seed: Uint8Array): KeyPair; +/** +* @param {WasmPrivateKey} sk +* @returns {WasmPublicKey} +*/ + getPublicKey(sk: WasmPrivateKey): WasmPublicKey; +/** +* @param {WasmPrivateKey} sk +* @param {WasmPublicKey} pk +* @returns {WasmSessionKey} +*/ + computeSharedSecret(sk: WasmPrivateKey, pk: WasmPublicKey): WasmSessionKey; +} + +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; + +export interface InitOutput { + readonly memory: WebAssembly.Memory; + readonly anoncredsSetDefaultLogger: () => number; + readonly anoncredsCreateSchema: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number; + readonly anoncredsCreateCredentialDefinition: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void; + readonly anoncredsCreateCredentialDefinitionCustom: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void; + readonly anoncredsValidateCredentialDefinitionFromJson: (a: number, b: number) => void; + readonly proverCreateLinkSecret: (a: number) => void; + readonly proverCreateCredentialRequest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; + readonly proverProcessCredential: (a: number, b: number, c: number, d: number, e: number) => number; + readonly proverCreatePresentation: (a: number, b: number, c: number, d: number, e: number, f: number) => number; + readonly issuerCreateSchema: () => number; + readonly issuerCreateCredentialOffer: (a: number, b: number) => void; + readonly issuerCreateCredential: (a: number, b: number, c: number, d: number) => number; + readonly generator_new: (a: number) => void; + readonly generator_toBytes: (a: number, b: number) => void; + readonly generator_fromBytes: (a: number, b: number, c: number) => void; + readonly __wbg_signkey_free: (a: number) => void; + readonly signkey_new: (a: number) => void; + readonly signkey_fromSeed: (a: number, b: number, c: number) => void; + readonly signkey_fromBytes: (a: number, b: number, c: number) => void; + readonly signkey_toBytes: (a: number, b: number) => void; + readonly verkey_new: (a: number, b: number, c: number) => void; + readonly verkey_fromBytes: (a: number, b: number, c: number) => void; + readonly verkey_toBytes: (a: number, b: number) => void; + readonly proofofpossession_new: (a: number, b: number, c: number) => void; + readonly __wbg_multisignature_free: (a: number) => void; + readonly multisignature_new: (a: number, b: number, c: number) => void; + readonly multisignature_fromBytes: (a: number, b: number, c: number) => void; + readonly multisignature_toBytes: (a: number, b: number) => void; + readonly __wbg_bls_free: (a: number) => void; + readonly bls_new: () => number; + readonly bls_sign: (a: number, b: number, c: number, d: number) => void; + readonly bls_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => void; + readonly bls_verifyProofOfPosession: (a: number, b: number, c: number, d: number) => void; + readonly bls_verifyMultiSignature: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; + readonly __wbg_credentialschema_free: (a: number) => void; + readonly credentialschema_new: () => number; + readonly credentialschema_addAttr: (a: number, b: number, c: number) => void; + readonly __wbg_credentialvalues_free: (a: number) => void; + readonly credentialvalues_addMasterSecret: (a: number, b: number, c: number) => void; + readonly credentialvalues_addKnown: (a: number, b: number, c: number, d: number, e: number, f: number) => void; + readonly credentialvalues_addHidden: (a: number, b: number, c: number, d: number, e: number, f: number) => void; + readonly credentialvalues_addCommitment: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void; + readonly __wbg_credentialprimarypublickey_free: (a: number) => void; + readonly __wbg_credentialpublickey_free: (a: number) => void; + readonly credentialpublickey_getPrimaryKey: (a: number, b: number) => void; + readonly credentialpublickey_getRevocationKey: (a: number, b: number) => void; + readonly __wbg_credentialrevocationpublickey_free: (a: number) => void; + readonly __wbg_credentialprivatekey_free: (a: number) => void; + readonly __wbg_credentialkeycorrectnessproof_free: (a: number) => void; + readonly __wbg_credentialdefinition_free: (a: number) => void; + readonly __wbg_mastersecret_free: (a: number) => void; + readonly mastersecret_new: (a: number) => void; + readonly nonce_new: (a: number) => void; + readonly __wbg_blindedcredentialsecrets_free: (a: number) => void; + readonly __wbg_credentialsecretsblindingfactors_free: (a: number) => void; + readonly __wbg_blindedcredentialsecretscorrectnessproof_free: (a: number) => void; + readonly __wbg_proverblindedcredentialsecrets_free: (a: number) => void; + readonly __wbg_credentialsignature_free: (a: number) => void; + readonly credentialsignature_extractIndex: (a: number, b: number) => void; + readonly __wbg_signaturecorrectnessproof_free: (a: number) => void; + readonly __wbg_issuedcredential_free: (a: number) => void; + readonly __wbg_issuedcredentialwithrevocation_free: (a: number) => void; + readonly __wbg_revocationpublickey_free: (a: number) => void; + readonly __wbg_revocationprivatekey_free: (a: number) => void; + readonly __wbg_revocationregistry_free: (a: number) => void; + readonly __wbg_revocationregistrydelta_free: (a: number) => void; + readonly revocationregistrydelta_fromParts: (a: number, b: number, c: number, d: number, e: number) => void; + readonly revocationregistrydelta_merge: (a: number, b: number, c: number) => void; + readonly __wbg_revocationtailsgenerator_free: (a: number) => void; + readonly revocationtailsgenerator_count: (a: number) => number; + readonly revocationtailsgenerator_next: (a: number, b: number) => void; + readonly __wbg_simpletailsaccessor_free: (a: number) => void; + readonly simpletailsaccessor_new: (a: number, b: number) => void; + readonly simpletailsaccessor_accessTail: (a: number, b: number, c: number) => void; + readonly witness_new: (a: number, b: number, c: number, d: number, e: number, f: number) => void; + readonly witness_update: (a: number, b: number, c: number, d: number, e: number, f: number) => void; + readonly __wbg_proof_free: (a: number) => void; + readonly __wbg_subproofrequest_free: (a: number) => void; + readonly subproofrequest_new: () => number; + readonly subproofrequest_addPredicate: (a: number, b: number, c: number, d: number, e: number, f: number) => void; + readonly __wbg_proofbuilder_free: (a: number) => void; + readonly proofbuilder_new: () => number; + readonly proofbuilder_addCommonAttribute: (a: number, b: number, c: number) => void; + readonly proofbuilder_addSubProofRequest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void; + readonly proofbuilder_finalize: (a: number, b: number, c: number) => void; + readonly __wbg_proofverifier_free: (a: number) => void; + readonly proofverifier_new: () => number; + readonly proofverifier_addSubProofRequest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void; + readonly proofverifier_verify: (a: number, b: number, c: number, d: number) => void; + readonly issuer_newCredentialDefinition: (a: number, b: number, c: number, d: number) => void; + readonly issuer_signCredential: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void; + readonly issuer_signCredentialWithRevocation: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number) => void; + readonly prover_blindedCredentialSecrets: (a: number, b: number, c: number, d: number, e: number) => void; + readonly prover_processCredentialSignature: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void; + readonly __wbg_ed25519sha512_free: (a: number) => void; + readonly ed25519sha512_new: (a: number) => void; + readonly ed25519sha512_fromSeed: (a: number, b: number, c: number) => void; + readonly ed25519sha512_fromPrivateKey: (a: number, b: number, c: number) => void; + readonly ed25519sha512_getPulicKey: (a: number, b: number) => void; + readonly ed25519sha512_sign: (a: number, b: number, c: number, d: number) => void; + readonly ed25519sha512_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; + readonly __wbg_wasmcipherkey_free: (a: number) => void; + readonly ursaencryptor_new: (a: number, b: number, c: number) => void; + readonly ursaencryptor_withKey: (a: number, b: number, c: number, d: number, e: number) => void; + readonly ursaencryptor_encrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; + readonly ursaencryptor_decrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; + readonly ecdsasecp256k1sha256_keypair: (a: number, b: number) => void; + readonly ecdsasecp256k1sha256_keypairFromSeed: (a: number, b: number, c: number, d: number) => void; + readonly ecdsasecp256k1sha256_getPublicKey: (a: number, b: number, c: number) => void; + readonly ecdsasecp256k1sha256_sign: (a: number, b: number, c: number, d: number, e: number) => void; + readonly ecdsasecp256k1sha256_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; + readonly ecdsasecp256k1sha256_normalizeS: (a: number, b: number, c: number, d: number, e: number) => void; + readonly ecdsasecp256k1sha256_publicKeyCompressed: (a: number, b: number) => number; + readonly ecdsasecp256k1sha256_publicKeyUnCompressed: (a: number, b: number) => number; + readonly ecdsasecp256k1sha256_parseToPublicKey: (a: number, b: number, c: number, d: number) => void; + readonly ecdhsecp256k1sha256_keypair: (a: number, b: number) => void; + readonly ecdhsecp256k1sha256_keypair_from_seed: (a: number, b: number, c: number, d: number) => void; + readonly ecdhsecp256k1sha256_getPublicKey: (a: number, b: number, c: number) => void; + readonly ecdhsecp256k1sha256_computeSharedSecret: (a: number, b: number, c: number, d: number) => void; + readonly x25519sha256_keypair: (a: number, b: number) => void; + readonly x25519sha256_keypair_from_seed: (a: number, b: number, c: number, d: number) => void; + readonly x25519sha256_getPublicKey: (a: number, b: number, c: number) => void; + readonly x25519sha256_computeSharedSecret: (a: number, b: number, c: number, d: number) => void; + readonly __wbg_wasmprivatekey_free: (a: number) => void; + readonly wasmpublickey_new: (a: number, b: number, c: number) => void; + readonly __wbg_nonce_free: (a: number) => void; + readonly signature_toBytes: (a: number, b: number) => void; + readonly proofofpossession_toBytes: (a: number, b: number) => void; + readonly __wbg_keypair_free: (a: number) => void; + readonly __wbg_noncredentialschema_free: (a: number) => void; + readonly ecdsasecp256k1sha256_new: () => number; + readonly ecdhsecp256k1sha256_new: () => number; + readonly x25519sha256_new: () => number; + readonly __wbg_issuer_free: (a: number) => void; + readonly __wbg_prover_free: (a: number) => void; + readonly __wbg_ursaencryptor_free: (a: number) => void; + readonly __wbg_ecdsasecp256k1sha256_free: (a: number) => void; + readonly __wbg_ecdhsecp256k1sha256_free: (a: number) => void; + readonly __wbg_x25519sha256_free: (a: number) => void; + readonly noncredentialschema_new: () => number; + readonly credentialvalues_new: () => number; + readonly __wbg_tail_free: (a: number) => void; + readonly __wbg_witness_free: (a: number) => void; + readonly noncredentialschema_addAttr: (a: number, b: number, c: number) => void; + readonly subproofrequest_addRevealedAttribute: (a: number, b: number, c: number) => void; + readonly __wbg_verkey_free: (a: number) => void; + readonly __wbg_signature_free: (a: number) => void; + readonly __wbg_proofofpossession_free: (a: number) => void; + readonly __wbg_generator_free: (a: number) => void; + readonly __wbg_wasmpublickey_free: (a: number) => void; + readonly __wbg_wasmsessionkey_free: (a: number) => void; + readonly signature_fromBytes: (a: number, b: number, c: number) => void; + readonly proofofpossession_fromBytes: (a: number, b: number, c: number) => void; + readonly __wbindgen_malloc: (a: number) => number; + readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; + readonly __wbindgen_add_to_stack_pointer: (a: number) => number; + readonly __wbindgen_free: (a: number, b: number) => void; + readonly __wbindgen_exn_store: (a: number) => void; +} + +export type SyncInitInput = BufferSource | WebAssembly.Module; +/** +* Instantiates the given `module`, which can either be bytes or +* a precompiled `WebAssembly.Module`. +* +* @param {SyncInitInput} module +* +* @returns {InitOutput} +*/ +export function initSync(module: SyncInitInput): InitOutput; + +/** +* If `module_or_path` is {RequestInfo} or {URL}, makes a request and +* for everything else, calls `WebAssembly.instantiate` directly. +* +* @param {InitInput | Promise} module_or_path +* +* @returns {Promise} +*/ +export default function init (module_or_path?: InitInput | Promise): Promise; diff --git a/anoncreds-rust/browser/anoncreds.js b/anoncreds-rust/browser/anoncreds.js new file mode 100644 index 000000000..3a667f79e --- /dev/null +++ b/anoncreds-rust/browser/anoncreds.js @@ -0,0 +1,3706 @@ +let wasm; + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const cachedTextEncoder = new TextEncoder('utf-8'); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length); + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len); + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3); + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +function getStringFromWasm0(ptr, len) { + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function getArrayU8FromWasm0(ptr, len) { + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedBigInt64Memory0 = null; + +function getBigInt64Memory0() { + if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) { + cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer); + } + return cachedBigInt64Memory0; +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} +/** +* @returns {number} +*/ +export function anoncredsSetDefaultLogger() { + const ret = wasm.anoncredsSetDefaultLogger(); + return ret >>> 0; +} + +let cachedUint32Memory0 = null; + +function getUint32Memory0() { + if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) { + cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer); + } + return cachedUint32Memory0; +} + +function passArrayJsValueToWasm0(array, malloc) { + const ptr = malloc(array.length * 4); + const mem = getUint32Memory0(); + for (let i = 0; i < array.length; i++) { + mem[ptr / 4 + i] = addHeapObject(array[i]); + } + WASM_VECTOR_LEN = array.length; + return ptr; +} +/** +* @param {string} name +* @param {string} version +* @param {string} issuer_id +* @param {any[]} attribute_names +* @returns {any} +*/ +export function anoncredsCreateSchema(name, version, issuer_id, attribute_names) { + const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(issuer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + const ptr3 = passArrayJsValueToWasm0(attribute_names, wasm.__wbindgen_malloc); + const len3 = WASM_VECTOR_LEN; + const ret = wasm.anoncredsCreateSchema(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); + return takeObject(ret); +} + +function getArrayJsValueFromWasm0(ptr, len) { + const mem = getUint32Memory0(); + const slice = mem.subarray(ptr / 4, ptr / 4 + len); + const result = []; + for (let i = 0; i < slice.length; i++) { + result.push(takeObject(slice[i])); + } + return result; +} +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @param {string} signature_type +* @param {boolean} support_revocation +* @returns {any[]} +*/ +export function anoncredsCreateCredentialDefinition(schema_id, schema, tag, issuer_id, signature_type, support_revocation) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(schema_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(issuer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + const ptr3 = passStringToWasm0(signature_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len3 = WASM_VECTOR_LEN; + wasm.anoncredsCreateCredentialDefinition(retptr, ptr0, len0, addHeapObject(schema), ptr1, len1, ptr2, len2, ptr3, len3, support_revocation); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v4 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v4; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +} + +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @returns {any[]} +*/ +export function anoncredsCreateCredentialDefinitionCustom(schema_id, schema, tag, issuer_id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(schema_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(issuer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + wasm.anoncredsCreateCredentialDefinitionCustom(retptr, ptr0, len0, addHeapObject(schema), ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v3 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v3; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +} + +/** +* @param {any} json +* @returns {boolean} +*/ +export function anoncredsValidateCredentialDefinitionFromJson(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.anoncredsValidateCredentialDefinitionFromJson(retptr, addHeapObject(json)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +} + +/** +* @returns {string} +*/ +export function proverCreateLinkSecret() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.proverCreateLinkSecret(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(r0, r1); + } +} + +/** +* @param {any} cred_offer +* @param {any} cred_def +* @param {string} link_secret +* @param {string} link_secret_id +* @returns {any[]} +*/ +export function proverCreateCredentialRequest(cred_offer, cred_def, link_secret, link_secret_id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(link_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(link_secret_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.proverCreateCredentialRequest(retptr, addHeapObject(cred_offer), addHeapObject(cred_def), ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v2 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v2; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +} + +/** +* @param {any} cred_def +* @param {any} credential +* @param {any} cred_req_meta +* @param {string} link_secret +* @returns {any} +*/ +export function proverProcessCredential(cred_def, credential, cred_req_meta, link_secret) { + const ptr0 = passStringToWasm0(link_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.proverProcessCredential(addHeapObject(cred_def), addHeapObject(credential), addHeapObject(cred_req_meta), ptr0, len0); + return takeObject(ret); +} + +/** +* @param {any} presentation_request +* @param {any} schema_dict +* @param {any} cred_def_dict +* @param {any} credential +* @param {string} link_secret +* @returns {any} +*/ +export function proverCreatePresentation(presentation_request, schema_dict, cred_def_dict, credential, link_secret) { + const ptr0 = passStringToWasm0(link_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.proverCreatePresentation(addHeapObject(presentation_request), addHeapObject(schema_dict), addHeapObject(cred_def_dict), addHeapObject(credential), ptr0, len0); + return takeObject(ret); +} + +/** +* @returns {any} +*/ +export function issuerCreateSchema() { + const ret = wasm.issuerCreateSchema(); + return takeObject(ret); +} + +/** +* @param {any} jsSchema +* @returns {any[]} +*/ +export function issuerCreateCredentialOffer(jsSchema) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.issuerCreateCredentialOffer(retptr, addHeapObject(jsSchema)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v0 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +} + +/** +* @param {any} jsCredOffer +* @param {any} jsCredDef +* @param {any} jsCredDefPriv +* @param {any} jsCredRequest +* @returns {any} +*/ +export function issuerCreateCredential(jsCredOffer, jsCredDef, jsCredDefPriv, jsCredRequest) { + const ret = wasm.issuerCreateCredential(addHeapObject(jsCredOffer), addHeapObject(jsCredDef), addHeapObject(jsCredDefPriv), addHeapObject(jsCredRequest)); + return takeObject(ret); +} + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1); + getUint8Memory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} + +function _assertClass(instance, klass) { + if (!(instance instanceof klass)) { + throw new Error(`expected instance of ${klass.name}`); + } + return instance.ptr; +} + +let stack_pointer = 128; + +function addBorrowedObject(obj) { + if (stack_pointer == 1) throw new Error('out of js stack'); + heap[--stack_pointer] = obj; + return stack_pointer; +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} +/** +*/ +export const ErrorCode = Object.freeze({ Success:0,"0":"Success",Input:1,"1":"Input",IOError:2,"2":"IOError",InvalidState:3,"3":"InvalidState",Unexpected:4,"4":"Unexpected",CredentialRevoked:5,"5":"CredentialRevoked",InvalidUserRevocId:6,"6":"InvalidUserRevocId",ProofRejected:7,"7":"ProofRejected",RevocationRegistryFull:8,"8":"RevocationRegistryFull", }); +/** +*/ +export class BlindedCredentialSecrets { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_blindedcredentialsecrets_free(ptr); + } +} +/** +*/ +export class BlindedCredentialSecretsCorrectnessProof { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_blindedcredentialsecretscorrectnessproof_free(ptr); + } +} +/** +*/ +export class Bls { + + static __wrap(ptr) { + const obj = Object.create(Bls.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_bls_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.bls_new(); + return Bls.__wrap(ret); + } + /** + * @param {Uint8Array} message + * @param {SignKey} sign_key + * @returns {Signature} + */ + static sign(message, sign_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(sign_key, SignKey); + wasm.bls_sign(retptr, ptr0, len0, sign_key.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Signature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {Signature} signature + * @param {VerKey} ver_key + * @param {Generator} generator + * @returns {boolean} + */ + static verify(message, signature, ver_key, generator) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(signature, Signature); + _assertClass(ver_key, VerKey); + _assertClass(generator, Generator); + wasm.bls_verify(retptr, ptr0, len0, signature.ptr, ver_key.ptr, generator.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {ProofOfPossession} pop + * @param {VerKey} ver_key + * @param {Generator} generator + * @returns {boolean} + */ + static verifyProofOfPosession(pop, ver_key, generator) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(pop, ProofOfPossession); + _assertClass(ver_key, VerKey); + _assertClass(generator, Generator); + wasm.bls_verifyProofOfPosession(retptr, pop.ptr, ver_key.ptr, generator.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {MultiSignature} multi_sig + * @param {Uint8Array} message + * @param {any[]} ver_keys + * @param {Generator} gen + * @returns {boolean} + */ + static verifyMultiSignature(multi_sig, message, ver_keys, gen) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(multi_sig, MultiSignature); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArrayJsValueToWasm0(ver_keys, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(gen, Generator); + wasm.bls_verifyMultiSignature(retptr, multi_sig.ptr, ptr0, len0, ptr1, len1, gen.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class CredentialDefinition { + + static __wrap(ptr) { + const obj = Object.create(CredentialDefinition.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialdefinition_free(ptr); + } +} +/** +*/ +export class CredentialKeyCorrectnessProof { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialkeycorrectnessproof_free(ptr); + } +} +/** +*/ +export class CredentialPrimaryPublicKey { + + static __wrap(ptr) { + const obj = Object.create(CredentialPrimaryPublicKey.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialprimarypublickey_free(ptr); + } +} +/** +*/ +export class CredentialPrivateKey { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialprivatekey_free(ptr); + } +} +/** +*/ +export class CredentialPublicKey { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialpublickey_free(ptr); + } + /** + * @returns {CredentialPrimaryPublicKey} + */ + getPrimaryKey() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credentialpublickey_getPrimaryKey(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return CredentialPrimaryPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {any} + */ + getRevocationKey() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credentialpublickey_getRevocationKey(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class CredentialRevocationPublicKey { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialrevocationpublickey_free(ptr); + } +} +/** +*/ +export class CredentialSchema { + + static __wrap(ptr) { + const obj = Object.create(CredentialSchema.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialschema_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.credentialschema_new(); + return CredentialSchema.__wrap(ret); + } + /** + * @param {string} attribute + */ + addAttr(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.credentialschema_addAttr(this.ptr, ptr0, len0); + } +} +/** +*/ +export class CredentialSecretsBlindingFactors { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialsecretsblindingfactors_free(ptr); + } +} +/** +*/ +export class CredentialSignature { + + static __wrap(ptr) { + const obj = Object.create(CredentialSignature.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialsignature_free(ptr); + } + /** + * @returns {number | undefined} + */ + extractIndex() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credentialsignature_extractIndex(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + return r0 === 0 ? undefined : r1 >>> 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class CredentialValues { + + static __wrap(ptr) { + const obj = Object.create(CredentialValues.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialvalues_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.credentialschema_new(); + return CredentialValues.__wrap(ret); + } + /** + * @param {MasterSecret} value + */ + addMasterSecret(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(value, MasterSecret); + wasm.credentialvalues_addMasterSecret(retptr, this.ptr, value.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} attr + * @param {string} value + */ + addKnown(attr, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.credentialvalues_addKnown(retptr, this.ptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} attr + * @param {string} value + */ + addHidden(attr, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.credentialvalues_addHidden(retptr, this.ptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} attr + * @param {string} value + * @param {string} blinding_factor + */ + addCommitment(attr, value, blinding_factor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(blinding_factor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + wasm.credentialvalues_addCommitment(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class EcdhSecp256k1Sha256 { + + static __wrap(ptr) { + const obj = Object.create(EcdhSecp256k1Sha256.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ecdhsecp256k1sha256_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.ecdsasecp256k1sha256_new(); + return EcdhSecp256k1Sha256.__wrap(ret); + } + /** + * @returns {KeyPair} + */ + keypair() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ecdhsecp256k1sha256_keypair(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {KeyPair} + */ + keypair_from_seed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ecdhsecp256k1sha256_keypair_from_seed(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @returns {WasmPublicKey} + */ + getPublicKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + wasm.ecdhsecp256k1sha256_getPublicKey(retptr, this.ptr, sk.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @param {WasmPublicKey} pk + * @returns {WasmSessionKey} + */ + computeSharedSecret(sk, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + _assertClass(pk, WasmPublicKey); + wasm.ecdhsecp256k1sha256_computeSharedSecret(retptr, this.ptr, sk.ptr, pk.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmSessionKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class EcdsaSecp256k1Sha256 { + + static __wrap(ptr) { + const obj = Object.create(EcdsaSecp256k1Sha256.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ecdsasecp256k1sha256_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.ecdsasecp256k1sha256_new(); + return EcdsaSecp256k1Sha256.__wrap(ret); + } + /** + * @returns {KeyPair} + */ + keypair() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ecdsasecp256k1sha256_keypair(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {KeyPair} + */ + keypairFromSeed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ecdsasecp256k1sha256_keypairFromSeed(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @returns {WasmPublicKey} + */ + getPublicKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + wasm.ecdsasecp256k1sha256_getPublicKey(retptr, this.ptr, sk.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {WasmPrivateKey} sk + * @returns {Uint8Array} + */ + sign(message, sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(sk, WasmPrivateKey); + wasm.ecdsasecp256k1sha256_sign(retptr, this.ptr, ptr0, len0, sk.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {Uint8Array} signature + * @param {WasmPublicKey} pk + * @returns {boolean} + */ + verify(message, signature, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(pk, WasmPublicKey); + wasm.ecdsasecp256k1sha256_verify(retptr, this.ptr, ptr0, len0, ptr1, len1, pk.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} signature + */ + normalizeS(signature) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + var ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.ecdsasecp256k1sha256_normalizeS(retptr, this.ptr, ptr0, len0, addHeapObject(signature)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPublicKey} pk + * @returns {WasmPublicKey} + */ + publicKeyCompressed(pk) { + _assertClass(pk, WasmPublicKey); + const ret = wasm.ecdsasecp256k1sha256_publicKeyCompressed(this.ptr, pk.ptr); + return WasmPublicKey.__wrap(ret); + } + /** + * @param {WasmPublicKey} pk + * @returns {WasmPublicKey} + */ + publicKeyUnCompressed(pk) { + _assertClass(pk, WasmPublicKey); + const ret = wasm.ecdsasecp256k1sha256_publicKeyUnCompressed(this.ptr, pk.ptr); + return WasmPublicKey.__wrap(ret); + } + /** + * @param {Uint8Array} bytes + * @returns {WasmPublicKey} + */ + parseToPublicKey(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ecdsasecp256k1sha256_parseToPublicKey(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Ed25519Sha512 { + + static __wrap(ptr) { + const obj = Object.create(Ed25519Sha512.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ed25519sha512_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ed25519sha512_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Ed25519Sha512.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {Ed25519Sha512} + */ + static fromSeed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ed25519sha512_fromSeed(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Ed25519Sha512.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} sk + * @returns {Ed25519Sha512} + */ + static fromPrivateKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ed25519sha512_fromPrivateKey(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Ed25519Sha512.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + getPulicKey() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ed25519sha512_getPulicKey(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @returns {Uint8Array} + */ + sign(message) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ed25519sha512_sign(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {Uint8Array} signature + * @param {Uint8Array} pk + * @returns {boolean} + */ + static verify(message, signature, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(pk, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + wasm.ed25519sha512_verify(retptr, ptr0, len0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Generator { + + static __wrap(ptr) { + const obj = Object.create(Generator.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_generator_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.generator_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Generator.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.generator_toBytes(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {Generator} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.generator_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Generator.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class IssuedCredential { + + static __wrap(ptr) { + const obj = Object.create(IssuedCredential.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuedcredential_free(ptr); + } +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class IssuedCredentialWithRevocation { + + static __wrap(ptr) { + const obj = Object.create(IssuedCredentialWithRevocation.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuedcredentialwithrevocation_free(ptr); + } +} +/** +*/ +export class Issuer { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuer_free(ptr); + } + /** + * @param {CredentialSchema} credential_schema + * @param {NonCredentialSchema} non_credential_schema + * @param {boolean} support_revocation + * @returns {CredentialDefinition} + */ + static newCredentialDefinition(credential_schema, non_credential_schema, support_revocation) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential_schema, CredentialSchema); + var ptr0 = credential_schema.__destroy_into_raw(); + _assertClass(non_credential_schema, NonCredentialSchema); + var ptr1 = non_credential_schema.__destroy_into_raw(); + wasm.issuer_newCredentialDefinition(retptr, ptr0, ptr1, support_revocation); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return CredentialDefinition.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} prover_id + * @param {BlindedCredentialSecrets} blinded_credential_secrets + * @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof + * @param {Nonce} credential_nonce + * @param {Nonce} credential_issuance_nonce + * @param {CredentialValues} credential_values + * @param {CredentialPublicKey} credential_pub_key + * @param {CredentialPrivateKey} credential_priv_key + * @returns {IssuedCredential} + */ + static signCredential(prover_id, blinded_credential_secrets, blinded_credential_secrets_correctness_proof, credential_nonce, credential_issuance_nonce, credential_values, credential_pub_key, credential_priv_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(prover_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(blinded_credential_secrets, BlindedCredentialSecrets); + _assertClass(blinded_credential_secrets_correctness_proof, BlindedCredentialSecretsCorrectnessProof); + _assertClass(credential_nonce, Nonce); + _assertClass(credential_issuance_nonce, Nonce); + _assertClass(credential_values, CredentialValues); + var ptr1 = credential_values.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(credential_priv_key, CredentialPrivateKey); + wasm.issuer_signCredential(retptr, ptr0, len0, blinded_credential_secrets.ptr, blinded_credential_secrets_correctness_proof.ptr, credential_nonce.ptr, credential_issuance_nonce.ptr, ptr1, credential_pub_key.ptr, credential_priv_key.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return IssuedCredential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} prover_id + * @param {BlindedCredentialSecrets} blinded_credential_secrets + * @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof + * @param {Nonce} credential_nonce + * @param {Nonce} credential_issuance_nonce + * @param {CredentialValues} credential_values + * @param {CredentialPublicKey} credential_pub_key + * @param {CredentialPrivateKey} credential_priv_key + * @param {number} rev_idx + * @param {number} max_cred_num + * @param {boolean} issuance_by_default + * @param {RevocationRegistry} rev_reg + * @param {RevocationPrivateKey} rev_key_priv + * @param {SimpleTailsAccessor} rev_tails_accessor + * @returns {IssuedCredentialWithRevocation} + */ + static signCredentialWithRevocation(prover_id, blinded_credential_secrets, blinded_credential_secrets_correctness_proof, credential_nonce, credential_issuance_nonce, credential_values, credential_pub_key, credential_priv_key, rev_idx, max_cred_num, issuance_by_default, rev_reg, rev_key_priv, rev_tails_accessor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(prover_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(blinded_credential_secrets, BlindedCredentialSecrets); + _assertClass(blinded_credential_secrets_correctness_proof, BlindedCredentialSecretsCorrectnessProof); + _assertClass(credential_nonce, Nonce); + _assertClass(credential_issuance_nonce, Nonce); + _assertClass(credential_values, CredentialValues); + var ptr1 = credential_values.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(credential_priv_key, CredentialPrivateKey); + _assertClass(rev_reg, RevocationRegistry); + _assertClass(rev_key_priv, RevocationPrivateKey); + _assertClass(rev_tails_accessor, SimpleTailsAccessor); + wasm.issuer_signCredentialWithRevocation(retptr, ptr0, len0, blinded_credential_secrets.ptr, blinded_credential_secrets_correctness_proof.ptr, credential_nonce.ptr, credential_issuance_nonce.ptr, ptr1, credential_pub_key.ptr, credential_priv_key.ptr, rev_idx, max_cred_num, issuance_by_default, rev_reg.ptr, rev_key_priv.ptr, rev_tails_accessor.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return IssuedCredentialWithRevocation.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class KeyPair { + + static __wrap(ptr) { + const obj = Object.create(KeyPair.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_keypair_free(ptr); + } +} +/** +*/ +export class MasterSecret { + + static __wrap(ptr) { + const obj = Object.create(MasterSecret.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_mastersecret_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.mastersecret_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MasterSecret.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class MultiSignature { + + static __wrap(ptr) { + const obj = Object.create(MultiSignature.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_multisignature_free(ptr); + } + /** + * @param {any[]} signatures + */ + constructor(signatures) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArrayJsValueToWasm0(signatures, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_new(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MultiSignature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {MultiSignature} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MultiSignature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.multisignature_toBytes(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class NonCredentialSchema { + + static __wrap(ptr) { + const obj = Object.create(NonCredentialSchema.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_noncredentialschema_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.credentialschema_new(); + return NonCredentialSchema.__wrap(ret); + } + /** + * @param {string} attribute + */ + addAttr(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.credentialschema_addAttr(this.ptr, ptr0, len0); + } +} +/** +*/ +export class Nonce { + + static __wrap(ptr) { + const obj = Object.create(Nonce.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_nonce_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.nonce_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Nonce.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Proof { + + static __wrap(ptr) { + const obj = Object.create(Proof.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proof_free(ptr); + } +} +/** +*/ +export class ProofBuilder { + + static __wrap(ptr) { + const obj = Object.create(ProofBuilder.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofbuilder_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.proofbuilder_new(); + return ProofBuilder.__wrap(ret); + } + /** + * @param {string} attribute + */ + addCommonAttribute(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.proofbuilder_addCommonAttribute(this.ptr, ptr0, len0); + } + /** + * @param {SubProofRequest} sub_proof_request + * @param {CredentialSchema} credential_schema + * @param {NonCredentialSchema} non_credential_schema + * @param {CredentialSignature} credential_signature + * @param {CredentialValues} credential_values + * @param {CredentialPublicKey} credential_pub_key + * @param {any} rev_reg + * @param {any} witness + */ + addSubProofRequest(sub_proof_request, credential_schema, non_credential_schema, credential_signature, credential_values, credential_pub_key, rev_reg, witness) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sub_proof_request, SubProofRequest); + var ptr0 = sub_proof_request.__destroy_into_raw(); + _assertClass(credential_schema, CredentialSchema); + var ptr1 = credential_schema.__destroy_into_raw(); + _assertClass(non_credential_schema, NonCredentialSchema); + var ptr2 = non_credential_schema.__destroy_into_raw(); + _assertClass(credential_signature, CredentialSignature); + _assertClass(credential_values, CredentialValues); + var ptr3 = credential_values.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + wasm.proofbuilder_addSubProofRequest(retptr, this.ptr, ptr0, ptr1, ptr2, credential_signature.ptr, ptr3, credential_pub_key.ptr, addBorrowedObject(rev_reg), addBorrowedObject(witness)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * @param {Nonce} nonce + * @returns {Proof} + */ + finalize(nonce) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(nonce, Nonce); + wasm.proofbuilder_finalize(retptr, this.ptr, nonce.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Proof.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class ProofOfPossession { + + static __wrap(ptr) { + const obj = Object.create(ProofOfPossession.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofofpossession_free(ptr); + } + /** + * @param {VerKey} ver_key + * @param {SignKey} sign_key + */ + constructor(ver_key, sign_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(ver_key, VerKey); + _assertClass(sign_key, SignKey); + wasm.proofofpossession_new(retptr, ver_key.ptr, sign_key.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return ProofOfPossession.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {ProofOfPossession} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return ProofOfPossession.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.multisignature_toBytes(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class ProofVerifier { + + static __wrap(ptr) { + const obj = Object.create(ProofVerifier.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofverifier_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.proofverifier_new(); + return ProofVerifier.__wrap(ret); + } + /** + * @param {SubProofRequest} sub_proof_request + * @param {CredentialSchema} credential_schema + * @param {NonCredentialSchema} non_credential_schema + * @param {CredentialPublicKey} credential_pub_key + * @param {any} rev_key_pub + * @param {any} rev_reg + */ + addSubProofRequest(sub_proof_request, credential_schema, non_credential_schema, credential_pub_key, rev_key_pub, rev_reg) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sub_proof_request, SubProofRequest); + var ptr0 = sub_proof_request.__destroy_into_raw(); + _assertClass(credential_schema, CredentialSchema); + var ptr1 = credential_schema.__destroy_into_raw(); + _assertClass(non_credential_schema, NonCredentialSchema); + var ptr2 = non_credential_schema.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + wasm.proofverifier_addSubProofRequest(retptr, this.ptr, ptr0, ptr1, ptr2, credential_pub_key.ptr, addBorrowedObject(rev_key_pub), addBorrowedObject(rev_reg)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * @param {Proof} proof + * @param {Nonce} nonce + * @returns {boolean} + */ + verify(proof, nonce) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(proof, Proof); + _assertClass(nonce, Nonce); + wasm.proofverifier_verify(retptr, this.ptr, proof.ptr, nonce.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Prover { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_prover_free(ptr); + } + /** + * @param {CredentialPublicKey} credential_pub_key + * @param {CredentialKeyCorrectnessProof} credential_key_correctness_proof + * @param {CredentialValues} credential_values + * @param {Nonce} credential_nonce + * @returns {ProverBlindedCredentialSecrets} + */ + static blindedCredentialSecrets(credential_pub_key, credential_key_correctness_proof, credential_values, credential_nonce) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(credential_key_correctness_proof, CredentialKeyCorrectnessProof); + _assertClass(credential_values, CredentialValues); + var ptr0 = credential_values.__destroy_into_raw(); + _assertClass(credential_nonce, Nonce); + wasm.prover_blindedCredentialSecrets(retptr, credential_pub_key.ptr, credential_key_correctness_proof.ptr, ptr0, credential_nonce.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return ProverBlindedCredentialSecrets.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {IssuedCredential} issued_credential + * @param {CredentialValues} credential_values + * @param {CredentialSecretsBlindingFactors} credential_secrets_blinding_factors + * @param {CredentialPublicKey} credential_pub_key + * @param {Nonce} nonce + * @param {any} rev_key_pub + * @param {any} rev_reg + * @param {any} witness + * @returns {CredentialSignature} + */ + static processCredentialSignature(issued_credential, credential_values, credential_secrets_blinding_factors, credential_pub_key, nonce, rev_key_pub, rev_reg, witness) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(issued_credential, IssuedCredential); + _assertClass(credential_values, CredentialValues); + var ptr0 = credential_values.__destroy_into_raw(); + _assertClass(credential_secrets_blinding_factors, CredentialSecretsBlindingFactors); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(nonce, Nonce); + wasm.prover_processCredentialSignature(retptr, issued_credential.ptr, ptr0, credential_secrets_blinding_factors.ptr, credential_pub_key.ptr, nonce.ptr, addBorrowedObject(rev_key_pub), addBorrowedObject(rev_reg), addBorrowedObject(witness)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return CredentialSignature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class ProverBlindedCredentialSecrets { + + static __wrap(ptr) { + const obj = Object.create(ProverBlindedCredentialSecrets.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proverblindedcredentialsecrets_free(ptr); + } +} +/** +*/ +export class RevocationPrivateKey { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationprivatekey_free(ptr); + } +} +/** +*/ +export class RevocationPublicKey { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationpublickey_free(ptr); + } +} +/** +*/ +export class RevocationRegistry { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationregistry_free(ptr); + } +} +/** +*/ +export class RevocationRegistryDelta { + + static __wrap(ptr) { + const obj = Object.create(RevocationRegistryDelta.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationregistrydelta_free(ptr); + } + /** + * @param {any} rev_reg_from + * @param {RevocationRegistry} rev_reg_to + * @param {any} issued + * @param {any} revoked + * @returns {RevocationRegistryDelta} + */ + static fromParts(rev_reg_from, rev_reg_to, issued, revoked) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_reg_to, RevocationRegistry); + wasm.revocationregistrydelta_fromParts(retptr, addBorrowedObject(rev_reg_from), rev_reg_to.ptr, addBorrowedObject(issued), addBorrowedObject(revoked)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return RevocationRegistryDelta.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * @param {RevocationRegistryDelta} other_delta + */ + merge(other_delta) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(other_delta, RevocationRegistryDelta); + wasm.revocationregistrydelta_merge(retptr, this.ptr, other_delta.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class RevocationTailsGenerator { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationtailsgenerator_free(ptr); + } + /** + * @returns {number} + */ + count() { + const ret = wasm.revocationtailsgenerator_count(this.ptr); + return ret >>> 0; + } + /** + * @returns {any} + */ + next() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.revocationtailsgenerator_next(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class SignKey { + + static __wrap(ptr) { + const obj = Object.create(SignKey.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_signkey_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.signkey_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SignKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {SignKey} + */ + static fromSeed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.signkey_fromSeed(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SignKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {SignKey} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.signkey_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SignKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.signkey_toBytes(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Signature { + + static __wrap(ptr) { + const obj = Object.create(Signature.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_signature_free(ptr); + } + /** + * @param {Uint8Array} bytes + * @returns {Signature} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Signature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.multisignature_toBytes(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class SignatureCorrectnessProof { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_signaturecorrectnessproof_free(ptr); + } +} +/** +*/ +export class SimpleTailsAccessor { + + static __wrap(ptr) { + const obj = Object.create(SimpleTailsAccessor.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_simpletailsaccessor_free(ptr); + } + /** + * @param {RevocationTailsGenerator} rev_tails_generator + */ + constructor(rev_tails_generator) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_tails_generator, RevocationTailsGenerator); + wasm.simpletailsaccessor_new(retptr, rev_tails_generator.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SimpleTailsAccessor.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {number} tail_id + * @param {Function} accessor + */ + accessTail(tail_id, accessor) { + try { + wasm.simpletailsaccessor_accessTail(this.ptr, tail_id, addBorrowedObject(accessor)); + } finally { + heap[stack_pointer++] = undefined; + } + } +} +/** +*/ +export class SubProofRequest { + + static __wrap(ptr) { + const obj = Object.create(SubProofRequest.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_subproofrequest_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.subproofrequest_new(); + return SubProofRequest.__wrap(ret); + } + /** + * @param {string} attribute + */ + addRevealedAttribute(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.credentialschema_addAttr(this.ptr, ptr0, len0); + } + /** + * @param {string} attribute + * @param {string} p_type + * @param {number} value + */ + addPredicate(attribute, p_type, value) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(p_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.subproofrequest_addPredicate(this.ptr, ptr0, len0, ptr1, len1, value); + } +} +/** +*/ +export class Tail { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_tail_free(ptr); + } +} +/** +*/ +export class UrsaEncryptor { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ursaencryptor_free(ptr); + } + /** + * @param {string} cipher + * @returns {WasmCipherKey} + */ + static new(cipher) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(cipher, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.ursaencryptor_new(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmCipherKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} cipher + * @param {string} key + * @returns {WasmCipherKey} + */ + static withKey(cipher, key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(cipher, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.ursaencryptor_withKey(retptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmCipherKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmCipherKey} cipher_key + * @param {Uint8Array} aad + * @param {Uint8Array} input + * @returns {Uint8Array} + */ + encrypt(cipher_key, aad, input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(cipher_key, WasmCipherKey); + var ptr0 = cipher_key.__destroy_into_raw(); + const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(input, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + wasm.ursaencryptor_encrypt(retptr, this.ptr, ptr0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v3 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v3; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmCipherKey} cipher_key + * @param {Uint8Array} aad + * @param {Uint8Array} input + * @returns {Uint8Array} + */ + decrypt(cipher_key, aad, input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(cipher_key, WasmCipherKey); + var ptr0 = cipher_key.__destroy_into_raw(); + const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(input, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + wasm.ursaencryptor_decrypt(retptr, this.ptr, ptr0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v3 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v3; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class VerKey { + + static __wrap(ptr) { + const obj = Object.create(VerKey.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_verkey_free(ptr); + } + /** + * @param {Generator} generator + * @param {SignKey} sign_key + */ + constructor(generator, sign_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(generator, Generator); + var ptr0 = generator.__destroy_into_raw(); + _assertClass(sign_key, SignKey); + var ptr1 = sign_key.__destroy_into_raw(); + wasm.verkey_new(retptr, ptr0, ptr1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return VerKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {VerKey} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.verkey_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return VerKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.verkey_toBytes(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class WasmCipherKey { + + static __wrap(ptr) { + const obj = Object.create(WasmCipherKey.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmcipherkey_free(ptr); + } +} +/** +*/ +export class WasmPrivateKey { + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmprivatekey_free(ptr); + } +} +/** +*/ +export class WasmPublicKey { + + static __wrap(ptr) { + const obj = Object.create(WasmPublicKey.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmpublickey_free(ptr); + } + /** + * @param {Uint8Array} key + */ + constructor(key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.wasmpublickey_new(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class WasmSessionKey { + + static __wrap(ptr) { + const obj = Object.create(WasmSessionKey.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmsessionkey_free(ptr); + } +} +/** +*/ +export class Witness { + + static __wrap(ptr) { + const obj = Object.create(Witness.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_witness_free(ptr); + } + /** + * @param {number} rev_idx + * @param {number} max_cred_num + * @param {boolean} issuance_by_default + * @param {RevocationRegistryDelta} rev_reg_delta + * @param {SimpleTailsAccessor} rev_tails_accessor + */ + constructor(rev_idx, max_cred_num, issuance_by_default, rev_reg_delta, rev_tails_accessor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_reg_delta, RevocationRegistryDelta); + _assertClass(rev_tails_accessor, SimpleTailsAccessor); + wasm.witness_new(retptr, rev_idx, max_cred_num, issuance_by_default, rev_reg_delta.ptr, rev_tails_accessor.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Witness.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {number} rev_idx + * @param {number} max_cred_num + * @param {RevocationRegistryDelta} rev_reg_delta + * @param {SimpleTailsAccessor} rev_tails_accessor + */ + update(rev_idx, max_cred_num, rev_reg_delta, rev_tails_accessor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_reg_delta, RevocationRegistryDelta); + _assertClass(rev_tails_accessor, SimpleTailsAccessor); + wasm.witness_update(retptr, this.ptr, rev_idx, max_cred_num, rev_reg_delta.ptr, rev_tails_accessor.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class X25519Sha256 { + + static __wrap(ptr) { + const obj = Object.create(X25519Sha256.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_x25519sha256_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.ecdsasecp256k1sha256_new(); + return X25519Sha256.__wrap(ret); + } + /** + * @returns {KeyPair} + */ + keypair() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.x25519sha256_keypair(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {KeyPair} + */ + keypair_from_seed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.x25519sha256_keypair_from_seed(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @returns {WasmPublicKey} + */ + getPublicKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + wasm.x25519sha256_getPublicKey(retptr, this.ptr, sk.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @param {WasmPublicKey} pk + * @returns {WasmSessionKey} + */ + computeSharedSecret(sk, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + _assertClass(pk, WasmPublicKey); + wasm.x25519sha256_computeSharedSecret(retptr, this.ptr, sk.ptr, pk.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmSessionKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} + +async function load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function getImports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_is_bigint = function(arg0) { + const ret = typeof(getObject(arg0)) === 'bigint'; + return ret; + }; + imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) { + const ret = arg0; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) { + const ret = getObject(arg0) === getObject(arg1); + return ret; + }; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len0; + getInt32Memory0()[arg0 / 4 + 0] = ptr0; + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbindgen_in = function(arg0, arg1) { + const ret = getObject(arg0) in getObject(arg1); + return ret; + }; + imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) { + const ret = BigInt.asUintN(64, arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbindgen_error_new = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_string = function(arg0) { + const ret = typeof(getObject(arg0)) === 'string'; + return ret; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) { + const ret = getObject(arg0) == getObject(arg1); + return ret; + }; + imports.wbg.__wbindgen_number_new = function(arg0) { + const ret = arg0; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) { + const ret = getObject(arg0)[getObject(arg1)]; + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + }; + imports.wbg.__wbg_debug_7960d327fd96f71a = function(arg0, arg1, arg2, arg3) { + console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); + }; + imports.wbg.__wbg_error_fe807da27c4a4ced = function(arg0) { + console.error(getObject(arg0)); + }; + imports.wbg.__wbg_error_fd84ca2a8a977774 = function(arg0, arg1, arg2, arg3) { + console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); + }; + imports.wbg.__wbg_info_5566be377f5b52ae = function(arg0, arg1, arg2, arg3) { + console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); + }; + imports.wbg.__wbg_log_7b690f184ae4519b = function(arg0, arg1, arg2, arg3) { + console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); + }; + imports.wbg.__wbg_warn_48cbddced45e5414 = function(arg0, arg1, arg2, arg3) { + console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); + }; + imports.wbg.__wbindgen_json_parse = function(arg0, arg1) { + const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = JSON.stringify(obj === undefined ? null : obj); + const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len0; + getInt32Memory0()[arg0 / 4 + 0] = ptr0; + }; + imports.wbg.__wbindgen_is_null = function(arg0) { + const ret = getObject(arg0) === null; + return ret; + }; + imports.wbg.__wbindgen_copy_to_typed_array = function(arg0, arg1, arg2) { + new Uint8Array(getObject(arg2).buffer, getObject(arg2).byteOffset, getObject(arg2).byteLength).set(getArrayU8FromWasm0(arg0, arg1)); + }; + imports.wbg.__wbg_getRandomValues_3774744e221a22ad = function() { return handleError(function (arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_randomFillSync_e950366c42764a07 = function() { return handleError(function (arg0, arg1) { + getObject(arg0).randomFillSync(takeObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_crypto_70a96de3b6b73dac = function(arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); + }; + imports.wbg.__wbg_process_dd1577445152112e = function(arg0) { + const ret = getObject(arg0).process; + return addHeapObject(ret); + }; + imports.wbg.__wbg_versions_58036bec3add9e6f = function(arg0) { + const ret = getObject(arg0).versions; + return addHeapObject(ret); + }; + imports.wbg.__wbg_node_6a9d28205ed5b0d8 = function(arg0) { + const ret = getObject(arg0).node; + return addHeapObject(ret); + }; + imports.wbg.__wbg_msCrypto_adbc770ec9eca9c7 = function(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); + }; + imports.wbg.__wbg_require_f05d779769764e82 = function() { return handleError(function () { + const ret = module.require; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbg_self_7eede1f4488bf346 = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_crypto_c909fb428dcbddb6 = function(arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); + }; + imports.wbg.__wbg_msCrypto_511eefefbfc70ae4 = function(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); + }; + imports.wbg.__wbg_static_accessor_MODULE_ef3aa2eb251158a5 = function() { + const ret = module; + return addHeapObject(ret); + }; + imports.wbg.__wbg_require_900d5c3984fe7703 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getRandomValues_307049345d0bd88c = function(arg0) { + const ret = getObject(arg0).getRandomValues; + return addHeapObject(ret); + }; + imports.wbg.__wbg_getRandomValues_cd175915511f705e = function(arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); + }; + imports.wbg.__wbg_randomFillSync_85b3f4c52c56c313 = function(arg0, arg1, arg2) { + getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2)); + }; + imports.wbg.__wbg_get_27fe3dac1c4d0224 = function(arg0, arg1) { + const ret = getObject(arg0)[arg1 >>> 0]; + return addHeapObject(ret); + }; + imports.wbg.__wbg_length_e498fbc24f9c1d4f = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_new_b525de17f44a8943 = function() { + const ret = new Array(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_newnoargs_2b8b6bd7753c76ba = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_f841cc6f2098f4b5 = function() { + const ret = new Map(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_next_b7d530c04fd8b217 = function(arg0) { + const ret = getObject(arg0).next; + return addHeapObject(ret); + }; + imports.wbg.__wbg_next_88560ec06a094dea = function() { return handleError(function (arg0) { + const ret = getObject(arg0).next(); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_done_1ebec03bbd919843 = function(arg0) { + const ret = getObject(arg0).done; + return ret; + }; + imports.wbg.__wbg_value_6ac8da5cc5b3efda = function(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); + }; + imports.wbg.__wbg_iterator_55f114446221aa5a = function() { + const ret = Symbol.iterator; + return addHeapObject(ret); + }; + imports.wbg.__wbg_get_baf4855f9a986186 = function() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(getObject(arg0), getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_call_95d1ea488d03e4e8 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_new_f9876326328f45ed = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_17224bc548dd1d7b = function(arg0, arg1, arg2) { + getObject(arg0)[arg1 >>> 0] = takeObject(arg2); + }; + imports.wbg.__wbg_isArray_39d28997bf6b96b4 = function(arg0) { + const ret = Array.isArray(getObject(arg0)); + return ret; + }; + imports.wbg.__wbg_instanceof_ArrayBuffer_a69f02ee4c4f5065 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof ArrayBuffer; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_call_9495de66fdbe016b = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_set_388c4c6422704173 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).set(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_isSafeInteger_8c4789029e885159 = function(arg0) { + const ret = Number.isSafeInteger(getObject(arg0)); + return ret; + }; + imports.wbg.__wbg_entries_4e1315b774245952 = function(arg0) { + const ret = Object.entries(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_cf65c07de34b9a08 = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_self_e7c1f827057f6584 = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_a09ec664e14b1b81 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_87cbb8506fecf3a9 = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_c85a9259e621f3db = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_newwithbyteoffsetandlength_9fb2f11355ecadf5 = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_537b7341ce90bb31 = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_17499e8aa4003ebd = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_27a2afe8ab42b09f = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Uint8Array_01cebe79ca606cca = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Uint8Array; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_newwithlength_b56c882b57805732 = function(arg0) { + const ret = new Uint8Array(arg0 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_subarray_7526649b91a252a6 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len0; + getInt32Memory0()[arg0 / 4 + 0] = ptr0; + }; + imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + try { + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(arg0, arg1); + } + }; + imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) { + const v = getObject(arg1); + const ret = typeof(v) === 'bigint' ? v : undefined; + getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len0; + getInt32Memory0()[arg0 / 4 + 0] = ptr0; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + + return imports; +} + +function initMemory(imports, maybe_memory) { + +} + +function finalizeInit(instance, module) { + wasm = instance.exports; + init.__wbindgen_wasm_module = module; + cachedBigInt64Memory0 = null; + cachedFloat64Memory0 = null; + cachedInt32Memory0 = null; + cachedUint32Memory0 = null; + cachedUint8Memory0 = null; + + + return wasm; +} + +function initSync(module) { + const imports = getImports(); + + initMemory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return finalizeInit(instance, module); +} + +async function init(input) { + if (typeof input === 'undefined') { + input = new URL('anoncreds_bg.wasm', import.meta.url); + } + const imports = getImports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + initMemory(imports); + + const { instance, module } = await load(await input, imports); + + return finalizeInit(instance, module); +} + +export { initSync } +export default init; diff --git a/anoncreds-rust/browser/anoncreds_bg.js b/anoncreds-rust/browser/anoncreds_bg.js new file mode 100644 index 000000000..c725c79bd --- /dev/null +++ b/anoncreds-rust/browser/anoncreds_bg.js @@ -0,0 +1,3717 @@ +let wasm; +export function __wbg_set_wasm(val) { + wasm = val; +} + + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; + +let cachedTextEncoder = new lTextEncoder('utf-8'); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; + +let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedBigInt64Memory0 = null; + +function getBigInt64Memory0() { + if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) { + cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer); + } + return cachedBigInt64Memory0; +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} +/** +* @returns {number} +*/ +export function anoncredsSetDefaultLogger() { + const ret = wasm.anoncredsSetDefaultLogger(); + return ret >>> 0; +} + +let cachedUint32Memory0 = null; + +function getUint32Memory0() { + if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) { + cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer); + } + return cachedUint32Memory0; +} + +function passArrayJsValueToWasm0(array, malloc) { + const ptr = malloc(array.length * 4) >>> 0; + const mem = getUint32Memory0(); + for (let i = 0; i < array.length; i++) { + mem[ptr / 4 + i] = addHeapObject(array[i]); + } + WASM_VECTOR_LEN = array.length; + return ptr; +} +/** +* @param {string} name +* @param {string} version +* @param {string} issuer_id +* @param {any[]} attribute_names +* @returns {any} +*/ +export function anoncredsCreateSchema(name, version, issuer_id, attribute_names) { + const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(issuer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + const ptr3 = passArrayJsValueToWasm0(attribute_names, wasm.__wbindgen_malloc); + const len3 = WASM_VECTOR_LEN; + const ret = wasm.anoncredsCreateSchema(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); + return takeObject(ret); +} + +function getArrayJsValueFromWasm0(ptr, len) { + ptr = ptr >>> 0; + const mem = getUint32Memory0(); + const slice = mem.subarray(ptr / 4, ptr / 4 + len); + const result = []; + for (let i = 0; i < slice.length; i++) { + result.push(takeObject(slice[i])); + } + return result; +} +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @param {string} signature_type +* @param {boolean} support_revocation +* @returns {any[]} +*/ +export function anoncredsCreateCredentialDefinition(schema_id, schema, tag, issuer_id, signature_type, support_revocation) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(schema_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(issuer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + const ptr3 = passStringToWasm0(signature_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len3 = WASM_VECTOR_LEN; + wasm.anoncredsCreateCredentialDefinition(retptr, ptr0, len0, addHeapObject(schema), ptr1, len1, ptr2, len2, ptr3, len3, support_revocation); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v5 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v5; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +} + +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @returns {any[]} +*/ +export function anoncredsCreateCredentialDefinitionCustom(schema_id, schema, tag, issuer_id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(schema_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(issuer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + wasm.anoncredsCreateCredentialDefinitionCustom(retptr, ptr0, len0, addHeapObject(schema), ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v4 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v4; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +} + +/** +* @param {any} json +* @returns {boolean} +*/ +export function anoncredsValidateCredentialDefinitionFromJson(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.anoncredsValidateCredentialDefinitionFromJson(retptr, addHeapObject(json)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +} + +/** +* @returns {string} +*/ +export function proverCreateLinkSecret() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.proverCreateLinkSecret(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1); + } +} + +/** +* @param {any} cred_offer +* @param {any} cred_def +* @param {string} link_secret +* @param {string} link_secret_id +* @returns {any[]} +*/ +export function proverCreateCredentialRequest(cred_offer, cred_def, link_secret, link_secret_id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(link_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(link_secret_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.proverCreateCredentialRequest(retptr, addHeapObject(cred_offer), addHeapObject(cred_def), ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v3 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v3; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +} + +/** +* @param {any} cred_def +* @param {any} credential +* @param {any} cred_req_meta +* @param {string} link_secret +* @returns {any} +*/ +export function proverProcessCredential(cred_def, credential, cred_req_meta, link_secret) { + const ptr0 = passStringToWasm0(link_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.proverProcessCredential(addHeapObject(cred_def), addHeapObject(credential), addHeapObject(cred_req_meta), ptr0, len0); + return takeObject(ret); +} + +/** +* @param {any} presentation_request +* @param {any} schema_dict +* @param {any} cred_def_dict +* @param {any} credential +* @param {string} link_secret +* @returns {any} +*/ +export function proverCreatePresentation(presentation_request, schema_dict, cred_def_dict, credential, link_secret) { + const ptr0 = passStringToWasm0(link_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.proverCreatePresentation(addHeapObject(presentation_request), addHeapObject(schema_dict), addHeapObject(cred_def_dict), addHeapObject(credential), ptr0, len0); + return takeObject(ret); +} + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1) >>> 0; + getUint8Memory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} + +function _assertClass(instance, klass) { + if (!(instance instanceof klass)) { + throw new Error(`expected instance of ${klass.name}`); + } + return instance.ptr; +} + +let stack_pointer = 128; + +function addBorrowedObject(obj) { + if (stack_pointer == 1) throw new Error('out of js stack'); + heap[--stack_pointer] = obj; + return stack_pointer; +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} +/** +*/ +export const ErrorCode = Object.freeze({ Success:0,"0":"Success",Input:1,"1":"Input",IOError:2,"2":"IOError",InvalidState:3,"3":"InvalidState",Unexpected:4,"4":"Unexpected",CredentialRevoked:5,"5":"CredentialRevoked",InvalidUserRevocId:6,"6":"InvalidUserRevocId",ProofRejected:7,"7":"ProofRejected",RevocationRegistryFull:8,"8":"RevocationRegistryFull", }); +/** +*/ +export class BlindedCredentialSecrets { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_blindedcredentialsecrets_free(ptr); + } +} +/** +*/ +export class BlindedCredentialSecretsCorrectnessProof { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_blindedcredentialsecretscorrectnessproof_free(ptr); + } +} +/** +*/ +export class Bls { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Bls.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_bls_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.bls_new(); + return Bls.__wrap(ret); + } + /** + * @param {Uint8Array} message + * @param {SignKey} sign_key + * @returns {Signature} + */ + static sign(message, sign_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(sign_key, SignKey); + wasm.bls_sign(retptr, ptr0, len0, sign_key.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Signature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {Signature} signature + * @param {VerKey} ver_key + * @param {Generator} generator + * @returns {boolean} + */ + static verify(message, signature, ver_key, generator) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(signature, Signature); + _assertClass(ver_key, VerKey); + _assertClass(generator, Generator); + wasm.bls_verify(retptr, ptr0, len0, signature.__wbg_ptr, ver_key.__wbg_ptr, generator.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {ProofOfPossession} pop + * @param {VerKey} ver_key + * @param {Generator} generator + * @returns {boolean} + */ + static verifyProofOfPosession(pop, ver_key, generator) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(pop, ProofOfPossession); + _assertClass(ver_key, VerKey); + _assertClass(generator, Generator); + wasm.bls_verifyProofOfPosession(retptr, pop.__wbg_ptr, ver_key.__wbg_ptr, generator.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {MultiSignature} multi_sig + * @param {Uint8Array} message + * @param {any[]} ver_keys + * @param {Generator} gen + * @returns {boolean} + */ + static verifyMultiSignature(multi_sig, message, ver_keys, gen) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(multi_sig, MultiSignature); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArrayJsValueToWasm0(ver_keys, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(gen, Generator); + wasm.bls_verifyMultiSignature(retptr, multi_sig.__wbg_ptr, ptr0, len0, ptr1, len1, gen.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class CredentialDefinition { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialDefinition.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialdefinition_free(ptr); + } +} +/** +*/ +export class CredentialKeyCorrectnessProof { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialkeycorrectnessproof_free(ptr); + } +} +/** +*/ +export class CredentialPrimaryPublicKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialPrimaryPublicKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialprimarypublickey_free(ptr); + } +} +/** +*/ +export class CredentialPrivateKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialprivatekey_free(ptr); + } +} +/** +*/ +export class CredentialPublicKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialpublickey_free(ptr); + } + /** + * @returns {CredentialPrimaryPublicKey} + */ + getPrimaryKey() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credentialpublickey_getPrimaryKey(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return CredentialPrimaryPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {any} + */ + getRevocationKey() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credentialpublickey_getRevocationKey(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class CredentialRevocationPublicKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialrevocationpublickey_free(ptr); + } +} +/** +*/ +export class CredentialSchema { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialSchema.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialschema_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.credentialschema_new(); + return CredentialSchema.__wrap(ret); + } + /** + * @param {string} attribute + */ + addAttr(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.credentialschema_addAttr(this.__wbg_ptr, ptr0, len0); + } +} +/** +*/ +export class CredentialSecretsBlindingFactors { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialsecretsblindingfactors_free(ptr); + } +} +/** +*/ +export class CredentialSignature { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialSignature.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialsignature_free(ptr); + } + /** + * @returns {number | undefined} + */ + extractIndex() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credentialsignature_extractIndex(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + return r0 === 0 ? undefined : r1 >>> 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class CredentialValues { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialValues.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialvalues_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.credentialschema_new(); + return CredentialValues.__wrap(ret); + } + /** + * @param {MasterSecret} value + */ + addMasterSecret(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(value, MasterSecret); + wasm.credentialvalues_addMasterSecret(retptr, this.__wbg_ptr, value.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} attr + * @param {string} value + */ + addKnown(attr, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.credentialvalues_addKnown(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} attr + * @param {string} value + */ + addHidden(attr, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.credentialvalues_addHidden(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} attr + * @param {string} value + * @param {string} blinding_factor + */ + addCommitment(attr, value, blinding_factor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(blinding_factor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + wasm.credentialvalues_addCommitment(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class EcdhSecp256k1Sha256 { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(EcdhSecp256k1Sha256.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ecdhsecp256k1sha256_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.ecdsasecp256k1sha256_new(); + return EcdhSecp256k1Sha256.__wrap(ret); + } + /** + * @returns {KeyPair} + */ + keypair() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ecdhsecp256k1sha256_keypair(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {KeyPair} + */ + keypair_from_seed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ecdhsecp256k1sha256_keypair_from_seed(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @returns {WasmPublicKey} + */ + getPublicKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + wasm.ecdhsecp256k1sha256_getPublicKey(retptr, this.__wbg_ptr, sk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @param {WasmPublicKey} pk + * @returns {WasmSessionKey} + */ + computeSharedSecret(sk, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + _assertClass(pk, WasmPublicKey); + wasm.ecdhsecp256k1sha256_computeSharedSecret(retptr, this.__wbg_ptr, sk.__wbg_ptr, pk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmSessionKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class EcdsaSecp256k1Sha256 { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(EcdsaSecp256k1Sha256.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ecdsasecp256k1sha256_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.ecdsasecp256k1sha256_new(); + return EcdsaSecp256k1Sha256.__wrap(ret); + } + /** + * @returns {KeyPair} + */ + keypair() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ecdsasecp256k1sha256_keypair(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {KeyPair} + */ + keypairFromSeed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ecdsasecp256k1sha256_keypairFromSeed(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @returns {WasmPublicKey} + */ + getPublicKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + wasm.ecdsasecp256k1sha256_getPublicKey(retptr, this.__wbg_ptr, sk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {WasmPrivateKey} sk + * @returns {Uint8Array} + */ + sign(message, sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(sk, WasmPrivateKey); + wasm.ecdsasecp256k1sha256_sign(retptr, this.__wbg_ptr, ptr0, len0, sk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v2 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v2; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {Uint8Array} signature + * @param {WasmPublicKey} pk + * @returns {boolean} + */ + verify(message, signature, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(pk, WasmPublicKey); + wasm.ecdsasecp256k1sha256_verify(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, pk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} signature + */ + normalizeS(signature) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + var ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.ecdsasecp256k1sha256_normalizeS(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(signature)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPublicKey} pk + * @returns {WasmPublicKey} + */ + publicKeyCompressed(pk) { + _assertClass(pk, WasmPublicKey); + const ret = wasm.ecdsasecp256k1sha256_publicKeyCompressed(this.__wbg_ptr, pk.__wbg_ptr); + return WasmPublicKey.__wrap(ret); + } + /** + * @param {WasmPublicKey} pk + * @returns {WasmPublicKey} + */ + publicKeyUnCompressed(pk) { + _assertClass(pk, WasmPublicKey); + const ret = wasm.ecdsasecp256k1sha256_publicKeyUnCompressed(this.__wbg_ptr, pk.__wbg_ptr); + return WasmPublicKey.__wrap(ret); + } + /** + * @param {Uint8Array} bytes + * @returns {WasmPublicKey} + */ + parseToPublicKey(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ecdsasecp256k1sha256_parseToPublicKey(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Ed25519Sha512 { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Ed25519Sha512.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ed25519sha512_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ed25519sha512_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Ed25519Sha512.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {Ed25519Sha512} + */ + static fromSeed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ed25519sha512_fromSeed(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Ed25519Sha512.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} sk + * @returns {Ed25519Sha512} + */ + static fromPrivateKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ed25519sha512_fromPrivateKey(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Ed25519Sha512.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + getPulicKey() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ed25519sha512_getPulicKey(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @returns {Uint8Array} + */ + sign(message) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ed25519sha512_sign(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v2 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v2; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {Uint8Array} signature + * @param {Uint8Array} pk + * @returns {boolean} + */ + static verify(message, signature, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(pk, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + wasm.ed25519sha512_verify(retptr, ptr0, len0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Generator { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Generator.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_generator_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.generator_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Generator.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.generator_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {Generator} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.generator_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Generator.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class IssuedCredential { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(IssuedCredential.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuedcredential_free(ptr); + } +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class IssuedCredentialWithRevocation { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(IssuedCredentialWithRevocation.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuedcredentialwithrevocation_free(ptr); + } +} +/** +*/ +export class Issuer { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuer_free(ptr); + } + /** + * @param {CredentialSchema} credential_schema + * @param {NonCredentialSchema} non_credential_schema + * @param {boolean} support_revocation + * @returns {CredentialDefinition} + */ + static newCredentialDefinition(credential_schema, non_credential_schema, support_revocation) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential_schema, CredentialSchema); + var ptr0 = credential_schema.__destroy_into_raw(); + _assertClass(non_credential_schema, NonCredentialSchema); + var ptr1 = non_credential_schema.__destroy_into_raw(); + wasm.issuer_newCredentialDefinition(retptr, ptr0, ptr1, support_revocation); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return CredentialDefinition.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} prover_id + * @param {BlindedCredentialSecrets} blinded_credential_secrets + * @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof + * @param {Nonce} credential_nonce + * @param {Nonce} credential_issuance_nonce + * @param {CredentialValues} credential_values + * @param {CredentialPublicKey} credential_pub_key + * @param {CredentialPrivateKey} credential_priv_key + * @returns {IssuedCredential} + */ + static signCredential(prover_id, blinded_credential_secrets, blinded_credential_secrets_correctness_proof, credential_nonce, credential_issuance_nonce, credential_values, credential_pub_key, credential_priv_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(prover_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(blinded_credential_secrets, BlindedCredentialSecrets); + _assertClass(blinded_credential_secrets_correctness_proof, BlindedCredentialSecretsCorrectnessProof); + _assertClass(credential_nonce, Nonce); + _assertClass(credential_issuance_nonce, Nonce); + _assertClass(credential_values, CredentialValues); + var ptr1 = credential_values.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(credential_priv_key, CredentialPrivateKey); + wasm.issuer_signCredential(retptr, ptr0, len0, blinded_credential_secrets.__wbg_ptr, blinded_credential_secrets_correctness_proof.__wbg_ptr, credential_nonce.__wbg_ptr, credential_issuance_nonce.__wbg_ptr, ptr1, credential_pub_key.__wbg_ptr, credential_priv_key.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return IssuedCredential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} prover_id + * @param {BlindedCredentialSecrets} blinded_credential_secrets + * @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof + * @param {Nonce} credential_nonce + * @param {Nonce} credential_issuance_nonce + * @param {CredentialValues} credential_values + * @param {CredentialPublicKey} credential_pub_key + * @param {CredentialPrivateKey} credential_priv_key + * @param {number} rev_idx + * @param {number} max_cred_num + * @param {boolean} issuance_by_default + * @param {RevocationRegistry} rev_reg + * @param {RevocationPrivateKey} rev_key_priv + * @param {SimpleTailsAccessor} rev_tails_accessor + * @returns {IssuedCredentialWithRevocation} + */ + static signCredentialWithRevocation(prover_id, blinded_credential_secrets, blinded_credential_secrets_correctness_proof, credential_nonce, credential_issuance_nonce, credential_values, credential_pub_key, credential_priv_key, rev_idx, max_cred_num, issuance_by_default, rev_reg, rev_key_priv, rev_tails_accessor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(prover_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(blinded_credential_secrets, BlindedCredentialSecrets); + _assertClass(blinded_credential_secrets_correctness_proof, BlindedCredentialSecretsCorrectnessProof); + _assertClass(credential_nonce, Nonce); + _assertClass(credential_issuance_nonce, Nonce); + _assertClass(credential_values, CredentialValues); + var ptr1 = credential_values.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(credential_priv_key, CredentialPrivateKey); + _assertClass(rev_reg, RevocationRegistry); + _assertClass(rev_key_priv, RevocationPrivateKey); + _assertClass(rev_tails_accessor, SimpleTailsAccessor); + wasm.issuer_signCredentialWithRevocation(retptr, ptr0, len0, blinded_credential_secrets.__wbg_ptr, blinded_credential_secrets_correctness_proof.__wbg_ptr, credential_nonce.__wbg_ptr, credential_issuance_nonce.__wbg_ptr, ptr1, credential_pub_key.__wbg_ptr, credential_priv_key.__wbg_ptr, rev_idx, max_cred_num, issuance_by_default, rev_reg.__wbg_ptr, rev_key_priv.__wbg_ptr, rev_tails_accessor.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return IssuedCredentialWithRevocation.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class KeyPair { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(KeyPair.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_keypair_free(ptr); + } +} +/** +*/ +export class MasterSecret { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(MasterSecret.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_mastersecret_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.mastersecret_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MasterSecret.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class MultiSignature { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(MultiSignature.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_multisignature_free(ptr); + } + /** + * @param {any[]} signatures + */ + constructor(signatures) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArrayJsValueToWasm0(signatures, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_new(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MultiSignature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {MultiSignature} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MultiSignature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.multisignature_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class NonCredentialSchema { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(NonCredentialSchema.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_noncredentialschema_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.credentialschema_new(); + return NonCredentialSchema.__wrap(ret); + } + /** + * @param {string} attribute + */ + addAttr(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.credentialschema_addAttr(this.__wbg_ptr, ptr0, len0); + } +} +/** +*/ +export class Nonce { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Nonce.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_nonce_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.nonce_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Nonce.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Proof { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Proof.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proof_free(ptr); + } +} +/** +*/ +export class ProofBuilder { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(ProofBuilder.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofbuilder_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.proofbuilder_new(); + return ProofBuilder.__wrap(ret); + } + /** + * @param {string} attribute + */ + addCommonAttribute(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.proofbuilder_addCommonAttribute(this.__wbg_ptr, ptr0, len0); + } + /** + * @param {SubProofRequest} sub_proof_request + * @param {CredentialSchema} credential_schema + * @param {NonCredentialSchema} non_credential_schema + * @param {CredentialSignature} credential_signature + * @param {CredentialValues} credential_values + * @param {CredentialPublicKey} credential_pub_key + * @param {any} rev_reg + * @param {any} witness + */ + addSubProofRequest(sub_proof_request, credential_schema, non_credential_schema, credential_signature, credential_values, credential_pub_key, rev_reg, witness) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sub_proof_request, SubProofRequest); + var ptr0 = sub_proof_request.__destroy_into_raw(); + _assertClass(credential_schema, CredentialSchema); + var ptr1 = credential_schema.__destroy_into_raw(); + _assertClass(non_credential_schema, NonCredentialSchema); + var ptr2 = non_credential_schema.__destroy_into_raw(); + _assertClass(credential_signature, CredentialSignature); + _assertClass(credential_values, CredentialValues); + var ptr3 = credential_values.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + wasm.proofbuilder_addSubProofRequest(retptr, this.__wbg_ptr, ptr0, ptr1, ptr2, credential_signature.__wbg_ptr, ptr3, credential_pub_key.__wbg_ptr, addBorrowedObject(rev_reg), addBorrowedObject(witness)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * @param {Nonce} nonce + * @returns {Proof} + */ + finalize(nonce) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(nonce, Nonce); + wasm.proofbuilder_finalize(retptr, this.__wbg_ptr, nonce.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Proof.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class ProofOfPossession { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(ProofOfPossession.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofofpossession_free(ptr); + } + /** + * @param {VerKey} ver_key + * @param {SignKey} sign_key + */ + constructor(ver_key, sign_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(ver_key, VerKey); + _assertClass(sign_key, SignKey); + wasm.proofofpossession_new(retptr, ver_key.__wbg_ptr, sign_key.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return ProofOfPossession.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {ProofOfPossession} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return ProofOfPossession.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.multisignature_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class ProofVerifier { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(ProofVerifier.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofverifier_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.proofverifier_new(); + return ProofVerifier.__wrap(ret); + } + /** + * @param {SubProofRequest} sub_proof_request + * @param {CredentialSchema} credential_schema + * @param {NonCredentialSchema} non_credential_schema + * @param {CredentialPublicKey} credential_pub_key + * @param {any} rev_key_pub + * @param {any} rev_reg + */ + addSubProofRequest(sub_proof_request, credential_schema, non_credential_schema, credential_pub_key, rev_key_pub, rev_reg) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sub_proof_request, SubProofRequest); + var ptr0 = sub_proof_request.__destroy_into_raw(); + _assertClass(credential_schema, CredentialSchema); + var ptr1 = credential_schema.__destroy_into_raw(); + _assertClass(non_credential_schema, NonCredentialSchema); + var ptr2 = non_credential_schema.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + wasm.proofverifier_addSubProofRequest(retptr, this.__wbg_ptr, ptr0, ptr1, ptr2, credential_pub_key.__wbg_ptr, addBorrowedObject(rev_key_pub), addBorrowedObject(rev_reg)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * @param {Proof} proof + * @param {Nonce} nonce + * @returns {boolean} + */ + verify(proof, nonce) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(proof, Proof); + _assertClass(nonce, Nonce); + wasm.proofverifier_verify(retptr, this.__wbg_ptr, proof.__wbg_ptr, nonce.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Prover { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_prover_free(ptr); + } + /** + * @param {CredentialPublicKey} credential_pub_key + * @param {CredentialKeyCorrectnessProof} credential_key_correctness_proof + * @param {CredentialValues} credential_values + * @param {Nonce} credential_nonce + * @returns {ProverBlindedCredentialSecrets} + */ + static blindedCredentialSecrets(credential_pub_key, credential_key_correctness_proof, credential_values, credential_nonce) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(credential_key_correctness_proof, CredentialKeyCorrectnessProof); + _assertClass(credential_values, CredentialValues); + var ptr0 = credential_values.__destroy_into_raw(); + _assertClass(credential_nonce, Nonce); + wasm.prover_blindedCredentialSecrets(retptr, credential_pub_key.__wbg_ptr, credential_key_correctness_proof.__wbg_ptr, ptr0, credential_nonce.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return ProverBlindedCredentialSecrets.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {IssuedCredential} issued_credential + * @param {CredentialValues} credential_values + * @param {CredentialSecretsBlindingFactors} credential_secrets_blinding_factors + * @param {CredentialPublicKey} credential_pub_key + * @param {Nonce} nonce + * @param {any} rev_key_pub + * @param {any} rev_reg + * @param {any} witness + * @returns {CredentialSignature} + */ + static processCredentialSignature(issued_credential, credential_values, credential_secrets_blinding_factors, credential_pub_key, nonce, rev_key_pub, rev_reg, witness) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(issued_credential, IssuedCredential); + _assertClass(credential_values, CredentialValues); + var ptr0 = credential_values.__destroy_into_raw(); + _assertClass(credential_secrets_blinding_factors, CredentialSecretsBlindingFactors); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(nonce, Nonce); + wasm.prover_processCredentialSignature(retptr, issued_credential.__wbg_ptr, ptr0, credential_secrets_blinding_factors.__wbg_ptr, credential_pub_key.__wbg_ptr, nonce.__wbg_ptr, addBorrowedObject(rev_key_pub), addBorrowedObject(rev_reg), addBorrowedObject(witness)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return CredentialSignature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class ProverBlindedCredentialSecrets { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(ProverBlindedCredentialSecrets.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proverblindedcredentialsecrets_free(ptr); + } +} +/** +*/ +export class RevocationPrivateKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationprivatekey_free(ptr); + } +} +/** +*/ +export class RevocationPublicKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationpublickey_free(ptr); + } +} +/** +*/ +export class RevocationRegistry { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationregistry_free(ptr); + } +} +/** +*/ +export class RevocationRegistryDelta { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(RevocationRegistryDelta.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationregistrydelta_free(ptr); + } + /** + * @param {any} rev_reg_from + * @param {RevocationRegistry} rev_reg_to + * @param {any} issued + * @param {any} revoked + * @returns {RevocationRegistryDelta} + */ + static fromParts(rev_reg_from, rev_reg_to, issued, revoked) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_reg_to, RevocationRegistry); + wasm.revocationregistrydelta_fromParts(retptr, addBorrowedObject(rev_reg_from), rev_reg_to.__wbg_ptr, addBorrowedObject(issued), addBorrowedObject(revoked)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return RevocationRegistryDelta.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * @param {RevocationRegistryDelta} other_delta + */ + merge(other_delta) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(other_delta, RevocationRegistryDelta); + wasm.revocationregistrydelta_merge(retptr, this.__wbg_ptr, other_delta.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class RevocationTailsGenerator { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationtailsgenerator_free(ptr); + } + /** + * @returns {number} + */ + count() { + const ret = wasm.revocationtailsgenerator_count(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @returns {any} + */ + next() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.revocationtailsgenerator_next(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class SignKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(SignKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_signkey_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.signkey_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SignKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {SignKey} + */ + static fromSeed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.signkey_fromSeed(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SignKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {SignKey} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.signkey_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SignKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.signkey_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class Signature { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Signature.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_signature_free(ptr); + } + /** + * @param {Uint8Array} bytes + * @returns {Signature} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Signature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.multisignature_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class SignatureCorrectnessProof { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_signaturecorrectnessproof_free(ptr); + } +} +/** +*/ +export class SimpleTailsAccessor { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(SimpleTailsAccessor.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_simpletailsaccessor_free(ptr); + } + /** + * @param {RevocationTailsGenerator} rev_tails_generator + */ + constructor(rev_tails_generator) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_tails_generator, RevocationTailsGenerator); + wasm.simpletailsaccessor_new(retptr, rev_tails_generator.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SimpleTailsAccessor.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {number} tail_id + * @param {Function} accessor + */ + accessTail(tail_id, accessor) { + try { + wasm.simpletailsaccessor_accessTail(this.__wbg_ptr, tail_id, addBorrowedObject(accessor)); + } finally { + heap[stack_pointer++] = undefined; + } + } +} +/** +*/ +export class SubProofRequest { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(SubProofRequest.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_subproofrequest_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.subproofrequest_new(); + return SubProofRequest.__wrap(ret); + } + /** + * @param {string} attribute + */ + addRevealedAttribute(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.credentialschema_addAttr(this.__wbg_ptr, ptr0, len0); + } + /** + * @param {string} attribute + * @param {string} p_type + * @param {number} value + */ + addPredicate(attribute, p_type, value) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(p_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.subproofrequest_addPredicate(this.__wbg_ptr, ptr0, len0, ptr1, len1, value); + } +} +/** +*/ +export class Tail { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_tail_free(ptr); + } +} +/** +*/ +export class UrsaEncryptor { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ursaencryptor_free(ptr); + } + /** + * @param {string} cipher + * @returns {WasmCipherKey} + */ + static new(cipher) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(cipher, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.ursaencryptor_new(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmCipherKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} cipher + * @param {string} key + * @returns {WasmCipherKey} + */ + static withKey(cipher, key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(cipher, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.ursaencryptor_withKey(retptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmCipherKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmCipherKey} cipher_key + * @param {Uint8Array} aad + * @param {Uint8Array} input + * @returns {Uint8Array} + */ + encrypt(cipher_key, aad, input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(cipher_key, WasmCipherKey); + var ptr0 = cipher_key.__destroy_into_raw(); + const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(input, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + wasm.ursaencryptor_encrypt(retptr, this.__wbg_ptr, ptr0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v4 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v4; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmCipherKey} cipher_key + * @param {Uint8Array} aad + * @param {Uint8Array} input + * @returns {Uint8Array} + */ + decrypt(cipher_key, aad, input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(cipher_key, WasmCipherKey); + var ptr0 = cipher_key.__destroy_into_raw(); + const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(input, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + wasm.ursaencryptor_decrypt(retptr, this.__wbg_ptr, ptr0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v4 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v4; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class VerKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(VerKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_verkey_free(ptr); + } + /** + * @param {Generator} generator + * @param {SignKey} sign_key + */ + constructor(generator, sign_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(generator, Generator); + var ptr0 = generator.__destroy_into_raw(); + _assertClass(sign_key, SignKey); + var ptr1 = sign_key.__destroy_into_raw(); + wasm.verkey_new(retptr, ptr0, ptr1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return VerKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {VerKey} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.verkey_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return VerKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.verkey_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class WasmCipherKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(WasmCipherKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmcipherkey_free(ptr); + } +} +/** +*/ +export class WasmPrivateKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmprivatekey_free(ptr); + } +} +/** +*/ +export class WasmPublicKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(WasmPublicKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmpublickey_free(ptr); + } + /** + * @param {Uint8Array} key + */ + constructor(key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.wasmpublickey_new(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class WasmSessionKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(WasmSessionKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmsessionkey_free(ptr); + } +} +/** +*/ +export class Witness { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Witness.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_witness_free(ptr); + } + /** + * @param {number} rev_idx + * @param {number} max_cred_num + * @param {boolean} issuance_by_default + * @param {RevocationRegistryDelta} rev_reg_delta + * @param {SimpleTailsAccessor} rev_tails_accessor + */ + constructor(rev_idx, max_cred_num, issuance_by_default, rev_reg_delta, rev_tails_accessor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_reg_delta, RevocationRegistryDelta); + _assertClass(rev_tails_accessor, SimpleTailsAccessor); + wasm.witness_new(retptr, rev_idx, max_cred_num, issuance_by_default, rev_reg_delta.__wbg_ptr, rev_tails_accessor.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Witness.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {number} rev_idx + * @param {number} max_cred_num + * @param {RevocationRegistryDelta} rev_reg_delta + * @param {SimpleTailsAccessor} rev_tails_accessor + */ + update(rev_idx, max_cred_num, rev_reg_delta, rev_tails_accessor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_reg_delta, RevocationRegistryDelta); + _assertClass(rev_tails_accessor, SimpleTailsAccessor); + wasm.witness_update(retptr, this.__wbg_ptr, rev_idx, max_cred_num, rev_reg_delta.__wbg_ptr, rev_tails_accessor.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class X25519Sha256 { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(X25519Sha256.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_x25519sha256_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.ecdsasecp256k1sha256_new(); + return X25519Sha256.__wrap(ret); + } + /** + * @returns {KeyPair} + */ + keypair() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.x25519sha256_keypair(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {KeyPair} + */ + keypair_from_seed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.x25519sha256_keypair_from_seed(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @returns {WasmPublicKey} + */ + getPublicKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + wasm.x25519sha256_getPublicKey(retptr, this.__wbg_ptr, sk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @param {WasmPublicKey} pk + * @returns {WasmSessionKey} + */ + computeSharedSecret(sk, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + _assertClass(pk, WasmPublicKey); + wasm.x25519sha256_computeSharedSecret(retptr, this.__wbg_ptr, sk.__wbg_ptr, pk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmSessionKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} + +export function __wbindgen_boolean_get(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; +}; + +export function __wbindgen_is_bigint(arg0) { + const ret = typeof(getObject(arg0)) === 'bigint'; + return ret; +}; + +export function __wbindgen_bigint_from_i64(arg0) { + const ret = arg0; + return addHeapObject(ret); +}; + +export function __wbindgen_jsval_eq(arg0, arg1) { + const ret = getObject(arg0) === getObject(arg1); + return ret; +}; + +export function __wbindgen_object_drop_ref(arg0) { + takeObject(arg0); +}; + +export function __wbindgen_number_get(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); +}; + +export function __wbindgen_string_get(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; +}; + +export function __wbindgen_is_object(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; +}; + +export function __wbindgen_in(arg0, arg1) { + const ret = getObject(arg0) in getObject(arg1); + return ret; +}; + +export function __wbindgen_bigint_from_u64(arg0) { + const ret = BigInt.asUintN(64, arg0); + return addHeapObject(ret); +}; + +export function __wbindgen_error_new(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +export function __wbindgen_is_string(arg0) { + const ret = typeof(getObject(arg0)) === 'string'; + return ret; +}; + +export function __wbindgen_is_undefined(arg0) { + const ret = getObject(arg0) === undefined; + return ret; +}; + +export function __wbindgen_string_new(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); +}; + +export function __wbindgen_jsval_loose_eq(arg0, arg1) { + const ret = getObject(arg0) == getObject(arg1); + return ret; +}; + +export function __wbindgen_number_new(arg0) { + const ret = arg0; + return addHeapObject(ret); +}; + +export function __wbindgen_object_clone_ref(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); +}; + +export function __wbg_getwithrefkey_15c62c2b8546208d(arg0, arg1) { + const ret = getObject(arg0)[getObject(arg1)]; + return addHeapObject(ret); +}; + +export function __wbg_set_20cbc34131e76824(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); +}; + +export function __wbg_debug_efabe4eb183aa5d4(arg0, arg1, arg2, arg3) { + console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +export function __wbg_error_a7e23606158b68b9(arg0) { + console.error(getObject(arg0)); +}; + +export function __wbg_error_50f42b952a595a23(arg0, arg1, arg2, arg3) { + console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +export function __wbg_info_24d8f53d98f12b95(arg0, arg1, arg2, arg3) { + console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +export function __wbg_log_9b164efbe6db702f(arg0, arg1, arg2, arg3) { + console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +export function __wbg_warn_8342bfbc6028193a(arg0, arg1, arg2, arg3) { + console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +export function __wbindgen_json_parse(arg0, arg1) { + const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +export function __wbindgen_json_serialize(arg0, arg1) { + const obj = getObject(arg1); + const ret = JSON.stringify(obj === undefined ? null : obj); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; +}; + +export function __wbindgen_is_null(arg0) { + const ret = getObject(arg0) === null; + return ret; +}; + +export function __wbindgen_copy_to_typed_array(arg0, arg1, arg2) { + new Uint8Array(getObject(arg2).buffer, getObject(arg2).byteOffset, getObject(arg2).byteLength).set(getArrayU8FromWasm0(arg0, arg1)); +}; + +export function __wbg_getRandomValues_37fa2ca9e4e07fab() { return handleError(function (arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); +}, arguments) }; + +export function __wbg_randomFillSync_dc1e9a60c158336d() { return handleError(function (arg0, arg1) { + getObject(arg0).randomFillSync(takeObject(arg1)); +}, arguments) }; + +export function __wbg_crypto_c48a774b022d20ac(arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); +}; + +export function __wbg_process_298734cf255a885d(arg0) { + const ret = getObject(arg0).process; + return addHeapObject(ret); +}; + +export function __wbg_versions_e2e78e134e3e5d01(arg0) { + const ret = getObject(arg0).versions; + return addHeapObject(ret); +}; + +export function __wbg_node_1cd7a5d853dbea79(arg0) { + const ret = getObject(arg0).node; + return addHeapObject(ret); +}; + +export function __wbg_msCrypto_bcb970640f50a1e8(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); +}; + +export function __wbg_require_8f08ceecec0f4fee() { return handleError(function () { + const ret = module.require; + return addHeapObject(ret); +}, arguments) }; + +export function __wbindgen_is_function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; +}; + +export function __wbg_self_7eede1f4488bf346() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); +}, arguments) }; + +export function __wbg_crypto_c909fb428dcbddb6(arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); +}; + +export function __wbg_msCrypto_511eefefbfc70ae4(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); +}; + +export function __wbg_static_accessor_MODULE_ef3aa2eb251158a5() { + const ret = module; + return addHeapObject(ret); +}; + +export function __wbg_require_900d5c3984fe7703(arg0, arg1, arg2) { + const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); +}; + +export function __wbg_getRandomValues_307049345d0bd88c(arg0) { + const ret = getObject(arg0).getRandomValues; + return addHeapObject(ret); +}; + +export function __wbg_getRandomValues_cd175915511f705e(arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); +}; + +export function __wbg_randomFillSync_85b3f4c52c56c313(arg0, arg1, arg2) { + getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2)); +}; + +export function __wbg_get_7303ed2ef026b2f5(arg0, arg1) { + const ret = getObject(arg0)[arg1 >>> 0]; + return addHeapObject(ret); +}; + +export function __wbg_length_820c786973abdd8a(arg0) { + const ret = getObject(arg0).length; + return ret; +}; + +export function __wbg_new_0394642eae39db16() { + const ret = new Array(); + return addHeapObject(ret); +}; + +export function __wbg_newnoargs_c9e6043b8ad84109(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +export function __wbg_new_0f2b71ca2f2a6029() { + const ret = new Map(); + return addHeapObject(ret); +}; + +export function __wbg_next_f4bc0e96ea67da68(arg0) { + const ret = getObject(arg0).next; + return addHeapObject(ret); +}; + +export function __wbg_next_ec061e48a0e72a96() { return handleError(function (arg0) { + const ret = getObject(arg0).next(); + return addHeapObject(ret); +}, arguments) }; + +export function __wbg_done_b6abb27d42b63867(arg0) { + const ret = getObject(arg0).done; + return ret; +}; + +export function __wbg_value_2f4ef2036bfad28e(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); +}; + +export function __wbg_iterator_7c7e58f62eb84700() { + const ret = Symbol.iterator; + return addHeapObject(ret); +}; + +export function __wbg_get_f53c921291c381bd() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(getObject(arg0), getObject(arg1)); + return addHeapObject(ret); +}, arguments) }; + +export function __wbg_call_557a2f2deacc4912() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); +}, arguments) }; + +export function __wbg_new_2b6fea4ea03b1b95() { + const ret = new Object(); + return addHeapObject(ret); +}; + +export function __wbg_set_b4da98d504ac6091(arg0, arg1, arg2) { + getObject(arg0)[arg1 >>> 0] = takeObject(arg2); +}; + +export function __wbg_isArray_04e59fb73f78ab5b(arg0) { + const ret = Array.isArray(getObject(arg0)); + return ret; +}; + +export function __wbg_instanceof_ArrayBuffer_ef2632aa0d4bfff8(arg0) { + let result; + try { + result = getObject(arg0) instanceof ArrayBuffer; + } catch { + result = false; + } + const ret = result; + return ret; +}; + +export function __wbg_call_587b30eea3e09332() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); +}, arguments) }; + +export function __wbg_set_da7be7bf0e037b14(arg0, arg1, arg2) { + const ret = getObject(arg0).set(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); +}; + +export function __wbg_isSafeInteger_2088b01008075470(arg0) { + const ret = Number.isSafeInteger(getObject(arg0)); + return ret; +}; + +export function __wbg_entries_13e011453776468f(arg0) { + const ret = Object.entries(getObject(arg0)); + return addHeapObject(ret); +}; + +export function __wbg_buffer_55ba7a6b1b92e2ac(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); +}; + +export function __wbg_self_742dd6eab3e9211e() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); +}, arguments) }; + +export function __wbg_window_c409e731db53a0e2() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); +}, arguments) }; + +export function __wbg_globalThis_b70c095388441f2d() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); +}, arguments) }; + +export function __wbg_global_1c72617491ed7194() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); +}, arguments) }; + +export function __wbg_newwithbyteoffsetandlength_88d1d8be5df94b9b(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); +}; + +export function __wbg_new_09938a7d020f049b(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); +}; + +export function __wbg_set_3698e3ca519b3c3c(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); +}; + +export function __wbg_length_0aab7ffd65ad19ed(arg0) { + const ret = getObject(arg0).length; + return ret; +}; + +export function __wbg_instanceof_Uint8Array_1349640af2da2e88(arg0) { + let result; + try { + result = getObject(arg0) instanceof Uint8Array; + } catch { + result = false; + } + const ret = result; + return ret; +}; + +export function __wbg_newwithlength_89eeca401d8918c2(arg0) { + const ret = new Uint8Array(arg0 >>> 0); + return addHeapObject(ret); +}; + +export function __wbg_subarray_d82be056deb4ad27(arg0, arg1, arg2) { + const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); +}; + +export function __wbg_new_abda76e883ba8a5f() { + const ret = new Error(); + return addHeapObject(ret); +}; + +export function __wbg_stack_658279fe44541cf6(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; +}; + +export function __wbg_error_f851667af71bcfc6(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1); + } +}; + +export function __wbindgen_bigint_get_as_i64(arg0, arg1) { + const v = getObject(arg1); + const ret = typeof(v) === 'bigint' ? v : undefined; + getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); +}; + +export function __wbindgen_debug_string(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; +}; + +export function __wbindgen_throw(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); +}; + +export function __wbindgen_memory() { + const ret = wasm.memory; + return addHeapObject(ret); +}; + diff --git a/anoncreds-rust/browser/anoncreds_bg.wasm b/anoncreds-rust/browser/anoncreds_bg.wasm new file mode 100644 index 000000000..5e09af7d9 Binary files /dev/null and b/anoncreds-rust/browser/anoncreds_bg.wasm differ diff --git a/anoncreds-rust/browser/anoncreds_bg.wasm.d.ts b/anoncreds-rust/browser/anoncreds_bg.wasm.d.ts new file mode 100644 index 000000000..11b26ebdf --- /dev/null +++ b/anoncreds-rust/browser/anoncreds_bg.wasm.d.ts @@ -0,0 +1,161 @@ +/* tslint:disable */ +/* eslint-disable */ +export const memory: WebAssembly.Memory; +export function anoncredsSetDefaultLogger(): number; +export function anoncredsCreateSchema(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; +export function anoncredsCreateCredentialDefinition(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number): void; +export function anoncredsCreateCredentialDefinitionCustom(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function anoncredsValidateCredentialDefinitionFromJson(a: number, b: number): void; +export function proverCreateLinkSecret(a: number): void; +export function proverCreateCredentialRequest(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function proverProcessCredential(a: number, b: number, c: number, d: number, e: number): number; +export function proverCreatePresentation(a: number, b: number, c: number, d: number, e: number, f: number): number; +export function issuerCreateSchema(): number; +export function issuerCreateCredentialOffer(a: number, b: number): void; +export function issuerCreateCredential(a: number, b: number, c: number, d: number): number; +export function generator_new(a: number): void; +export function generator_toBytes(a: number, b: number): void; +export function generator_fromBytes(a: number, b: number, c: number): void; +export function __wbg_signkey_free(a: number): void; +export function signkey_new(a: number): void; +export function signkey_fromSeed(a: number, b: number, c: number): void; +export function signkey_fromBytes(a: number, b: number, c: number): void; +export function signkey_toBytes(a: number, b: number): void; +export function verkey_new(a: number, b: number, c: number): void; +export function verkey_fromBytes(a: number, b: number, c: number): void; +export function verkey_toBytes(a: number, b: number): void; +export function proofofpossession_new(a: number, b: number, c: number): void; +export function __wbg_multisignature_free(a: number): void; +export function multisignature_new(a: number, b: number, c: number): void; +export function multisignature_fromBytes(a: number, b: number, c: number): void; +export function multisignature_toBytes(a: number, b: number): void; +export function __wbg_bls_free(a: number): void; +export function bls_new(): number; +export function bls_sign(a: number, b: number, c: number, d: number): void; +export function bls_verify(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function bls_verifyProofOfPosession(a: number, b: number, c: number, d: number): void; +export function bls_verifyMultiSignature(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function __wbg_credentialschema_free(a: number): void; +export function credentialschema_new(): number; +export function credentialschema_addAttr(a: number, b: number, c: number): void; +export function __wbg_credentialvalues_free(a: number): void; +export function credentialvalues_addMasterSecret(a: number, b: number, c: number): void; +export function credentialvalues_addKnown(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function credentialvalues_addHidden(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function credentialvalues_addCommitment(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function __wbg_credentialprimarypublickey_free(a: number): void; +export function __wbg_credentialpublickey_free(a: number): void; +export function credentialpublickey_getPrimaryKey(a: number, b: number): void; +export function credentialpublickey_getRevocationKey(a: number, b: number): void; +export function __wbg_credentialrevocationpublickey_free(a: number): void; +export function __wbg_credentialprivatekey_free(a: number): void; +export function __wbg_credentialkeycorrectnessproof_free(a: number): void; +export function __wbg_credentialdefinition_free(a: number): void; +export function __wbg_mastersecret_free(a: number): void; +export function mastersecret_new(a: number): void; +export function nonce_new(a: number): void; +export function __wbg_blindedcredentialsecrets_free(a: number): void; +export function __wbg_credentialsecretsblindingfactors_free(a: number): void; +export function __wbg_blindedcredentialsecretscorrectnessproof_free(a: number): void; +export function __wbg_proverblindedcredentialsecrets_free(a: number): void; +export function __wbg_credentialsignature_free(a: number): void; +export function credentialsignature_extractIndex(a: number, b: number): void; +export function __wbg_signaturecorrectnessproof_free(a: number): void; +export function __wbg_issuedcredential_free(a: number): void; +export function __wbg_issuedcredentialwithrevocation_free(a: number): void; +export function __wbg_revocationpublickey_free(a: number): void; +export function __wbg_revocationprivatekey_free(a: number): void; +export function __wbg_revocationregistry_free(a: number): void; +export function __wbg_revocationregistrydelta_free(a: number): void; +export function revocationregistrydelta_fromParts(a: number, b: number, c: number, d: number, e: number): void; +export function revocationregistrydelta_merge(a: number, b: number, c: number): void; +export function __wbg_revocationtailsgenerator_free(a: number): void; +export function revocationtailsgenerator_count(a: number): number; +export function revocationtailsgenerator_next(a: number, b: number): void; +export function __wbg_simpletailsaccessor_free(a: number): void; +export function simpletailsaccessor_new(a: number, b: number): void; +export function simpletailsaccessor_accessTail(a: number, b: number, c: number): void; +export function witness_new(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function witness_update(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function __wbg_proof_free(a: number): void; +export function __wbg_subproofrequest_free(a: number): void; +export function subproofrequest_new(): number; +export function subproofrequest_addPredicate(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function __wbg_proofbuilder_free(a: number): void; +export function proofbuilder_new(): number; +export function proofbuilder_addCommonAttribute(a: number, b: number, c: number): void; +export function proofbuilder_addSubProofRequest(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; +export function proofbuilder_finalize(a: number, b: number, c: number): void; +export function __wbg_proofverifier_free(a: number): void; +export function proofverifier_new(): number; +export function proofverifier_addSubProofRequest(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function proofverifier_verify(a: number, b: number, c: number, d: number): void; +export function issuer_newCredentialDefinition(a: number, b: number, c: number, d: number): void; +export function issuer_signCredential(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; +export function issuer_signCredentialWithRevocation(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number): void; +export function prover_blindedCredentialSecrets(a: number, b: number, c: number, d: number, e: number): void; +export function prover_processCredentialSignature(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number): void; +export function __wbg_ed25519sha512_free(a: number): void; +export function ed25519sha512_new(a: number): void; +export function ed25519sha512_fromSeed(a: number, b: number, c: number): void; +export function ed25519sha512_fromPrivateKey(a: number, b: number, c: number): void; +export function ed25519sha512_getPulicKey(a: number, b: number): void; +export function ed25519sha512_sign(a: number, b: number, c: number, d: number): void; +export function ed25519sha512_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function __wbg_wasmcipherkey_free(a: number): void; +export function ursaencryptor_new(a: number, b: number, c: number): void; +export function ursaencryptor_withKey(a: number, b: number, c: number, d: number, e: number): void; +export function ursaencryptor_encrypt(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function ursaencryptor_decrypt(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function ecdsasecp256k1sha256_keypair(a: number, b: number): void; +export function ecdsasecp256k1sha256_keypairFromSeed(a: number, b: number, c: number, d: number): void; +export function ecdsasecp256k1sha256_getPublicKey(a: number, b: number, c: number): void; +export function ecdsasecp256k1sha256_sign(a: number, b: number, c: number, d: number, e: number): void; +export function ecdsasecp256k1sha256_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function ecdsasecp256k1sha256_normalizeS(a: number, b: number, c: number, d: number, e: number): void; +export function ecdsasecp256k1sha256_publicKeyCompressed(a: number, b: number): number; +export function ecdsasecp256k1sha256_publicKeyUnCompressed(a: number, b: number): number; +export function ecdsasecp256k1sha256_parseToPublicKey(a: number, b: number, c: number, d: number): void; +export function ecdhsecp256k1sha256_keypair(a: number, b: number): void; +export function ecdhsecp256k1sha256_keypair_from_seed(a: number, b: number, c: number, d: number): void; +export function ecdhsecp256k1sha256_getPublicKey(a: number, b: number, c: number): void; +export function ecdhsecp256k1sha256_computeSharedSecret(a: number, b: number, c: number, d: number): void; +export function x25519sha256_keypair(a: number, b: number): void; +export function x25519sha256_keypair_from_seed(a: number, b: number, c: number, d: number): void; +export function x25519sha256_getPublicKey(a: number, b: number, c: number): void; +export function x25519sha256_computeSharedSecret(a: number, b: number, c: number, d: number): void; +export function __wbg_wasmprivatekey_free(a: number): void; +export function wasmpublickey_new(a: number, b: number, c: number): void; +export function __wbg_nonce_free(a: number): void; +export function signature_toBytes(a: number, b: number): void; +export function proofofpossession_toBytes(a: number, b: number): void; +export function __wbg_keypair_free(a: number): void; +export function __wbg_noncredentialschema_free(a: number): void; +export function ecdsasecp256k1sha256_new(): number; +export function ecdhsecp256k1sha256_new(): number; +export function x25519sha256_new(): number; +export function __wbg_issuer_free(a: number): void; +export function __wbg_prover_free(a: number): void; +export function __wbg_ursaencryptor_free(a: number): void; +export function __wbg_ecdsasecp256k1sha256_free(a: number): void; +export function __wbg_ecdhsecp256k1sha256_free(a: number): void; +export function __wbg_x25519sha256_free(a: number): void; +export function noncredentialschema_new(): number; +export function credentialvalues_new(): number; +export function __wbg_tail_free(a: number): void; +export function __wbg_witness_free(a: number): void; +export function noncredentialschema_addAttr(a: number, b: number, c: number): void; +export function subproofrequest_addRevealedAttribute(a: number, b: number, c: number): void; +export function __wbg_verkey_free(a: number): void; +export function __wbg_signature_free(a: number): void; +export function __wbg_proofofpossession_free(a: number): void; +export function __wbg_generator_free(a: number): void; +export function __wbg_wasmpublickey_free(a: number): void; +export function __wbg_wasmsessionkey_free(a: number): void; +export function signature_fromBytes(a: number, b: number, c: number): void; +export function proofofpossession_fromBytes(a: number, b: number, c: number): void; +export function __wbindgen_malloc(a: number): number; +export function __wbindgen_realloc(a: number, b: number, c: number): number; +export function __wbindgen_add_to_stack_pointer(a: number): number; +export function __wbindgen_free(a: number, b: number): void; +export function __wbindgen_exn_store(a: number): void; diff --git a/anoncreds-rust/browser/package.json b/anoncreds-rust/browser/package.json new file mode 100644 index 000000000..6132052e0 --- /dev/null +++ b/anoncreds-rust/browser/package.json @@ -0,0 +1,29 @@ +{ + "name": "anoncreds", + "collaborators": [ + "Hyperledger AnonCreds Contributors " + ], + "description": "Verifiable credential issuance and presentation for Hyperledger AnonCreds (https://www.hyperledger.org/projects), which provides a foundation for self-sovereign identity.", + "version": "0.1.0-dev.16", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/hyperledger/anoncreds-rs/" + }, + "files": [ + "anoncreds_bg.wasm", + "anoncreds.js", + "anoncreds.d.ts" + ], + "module": "anoncreds.js", + "types": "anoncreds.d.ts", + "sideEffects": [ + "./snippets/*" + ], + "keywords": [ + "hyperledger", + "ssi", + "verifiable", + "credentials" + ] +} \ No newline at end of file diff --git a/anoncreds-rust/node/LICENSE b/anoncreds-rust/node/LICENSE new file mode 100644 index 000000000..11153de76 --- /dev/null +++ b/anoncreds-rust/node/LICENSE @@ -0,0 +1,192 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2017 Sovrin Foundation + Copyright 2020 Province of British Columbia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/anoncreds-rust/node/README.md b/anoncreds-rust/node/README.md new file mode 100644 index 000000000..7281f5261 --- /dev/null +++ b/anoncreds-rust/node/README.md @@ -0,0 +1,77 @@ +# anoncreds-rs + +Rust library and reference implementation of the [Anoncreds V1.0 +specification](https://hyperledger.github.io/anoncreds-spec/). + +The AnonCreds (Anonymous Credentials) specification is based on the open source +verifiable credential implementation of AnonCreds that has been in use since +2017, initially as part of the Hyperledger Indy open source project and now in +the Hyperledger AnonCreds project. The extensive use of AnonCreds around the +world has made it a de facto standard for ZKP-based verifiable credentials, and +this specification is the formalization of that implementation. + +## Library + +Anoncreds-rs exposes three main parts: [`issuer`](./src/services/issuer.rs), +[`prover`](./src/services/prover.rs) and +[`verifier`](./src/services/verifier.rs). + +### Issuer + +- Create a [schema](https://hyperledger.github.io/anoncreds-spec/#schema-publisher-publish-schema-object) +- Create a [credential definition](https://hyperledger.github.io/anoncreds-spec/#issuer-create-and-publish-credential-definition-object) +- Create a [revocation registry definition](https://hyperledger.github.io/anoncreds-spec/#issuer-create-and-publish-revocation-registry-objects) +- Create a [revocation status list](https://hyperledger.github.io/anoncreds-spec/#publishing-the-initial-initial-revocation-status-list-object) +- Update a [revocation status list](https://hyperledger.github.io/anoncreds-spec/#publishing-the-initial-initial-revocation-status-list-object) +- Update a [revocation status list](https://hyperledger.github.io/anoncreds-spec/#publishing-the-initial-initial-revocation-status-list-object)'s timestamp +- Create a [credential offer](https://hyperledger.github.io/anoncreds-spec/#credential-offer) +- Create a [credential](https://hyperledger.github.io/anoncreds-spec/#issue-credential) + +### Prover / Holder + +- Create a [credential request](https://hyperledger.github.io/anoncreds-spec/#credential-request) +- Process an incoming [credential](https://hyperledger.github.io/anoncreds-spec/#receiving-a-credential) +- Create a [presentation](https://hyperledger.github.io/anoncreds-spec/#generate-presentation) +- Create, and update, a revocation state +- Create, and update, a revocation state with a witness + +### Verifier + +- [Verify a presentation](https://hyperledger.github.io/anoncreds-spec/#verify-presentation) +- generate a nonce + +## Wrappers + +Anoncreds is, soon, available as a standalone library in Rust, but also via wrappers. + +| Language | Directory | Status | +| ------------ | --------------------------------------------------------------------------------------- | ------ | +| Node.js | [javascript](https://github.com/hyperledger/anoncreds-rs/tree/main/wrappers/javascript) | ✅ | +| React Native | [javascript](https://github.com/hyperledger/anoncreds-rs/tree/main/wrappers/javascript) | ✅ | +| Python | [python](https://github.com/hyperledger/anoncreds-rs/tree/main/wrappers/python) | 🚧 | + + +## Credit + +The initial implementation of `anoncreds-rs` is derived from `indy-shared-rs` +that was developed by the Verifiable Organizations Network (VON) team based at +the Province of British Columbia, and derives largely from the implementations +within [Hyperledger Indy-SDK](https://github.com/hyperledger/indy-sdk). To +learn more about VON and what's happening with decentralized identity in +British Columbia, please go to [https://vonx.io](https://vonx.io). + +## Contributing + +Pull requests are welcome! Please read our [contributions +guide](https://github.com/hyperledger/anoncreds-rs/blob/main/CONTRIBUTING.md) +and submit your PRs. We enforce [developer certificate of +origin](https://developercertificate.org/) (DCO) commit signing. See guidance +[here](https://github.com/apps/dco). + +We also welcome issues submitted about problems you encounter in using +`anoncreds-rs` or any of the wrappers. + +## License + +[Apache License Version +2.0](https://github.com/hyperledger/anoncreds-rs/blob/main/LICENSE) diff --git a/anoncreds-rust/node/anoncreds.d.ts b/anoncreds-rust/node/anoncreds.d.ts new file mode 100644 index 000000000..ca4bbf765 --- /dev/null +++ b/anoncreds-rust/node/anoncreds.d.ts @@ -0,0 +1,812 @@ +/* tslint:disable */ +/* eslint-disable */ +/** +* @returns {number} +*/ +export function anoncredsSetDefaultLogger(): number; +/** +* @param {string} name +* @param {string} version +* @param {string} issuer_id +* @param {any[]} attribute_names +* @returns {any} +*/ +export function anoncredsCreateSchema(name: string, version: string, issuer_id: string, attribute_names: any[]): any; +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @param {string} signature_type +* @param {boolean} support_revocation +* @returns {any[]} +*/ +export function anoncredsCreateCredentialDefinition(schema_id: string, schema: any, tag: string, issuer_id: string, signature_type: string, support_revocation: boolean): any[]; +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @returns {any[]} +*/ +export function anoncredsCreateCredentialDefinitionCustom(schema_id: string, schema: any, tag: string, issuer_id: string): any[]; +/** +* @param {any} json +* @returns {boolean} +*/ +export function anoncredsValidateCredentialDefinitionFromJson(json: any): boolean; +/** +* @returns {string} +*/ +export function proverCreateLinkSecret(): string; +/** +* @param {any} cred_offer +* @param {any} cred_def +* @param {string} link_secret +* @param {string} link_secret_id +* @returns {any[]} +*/ +export function proverCreateCredentialRequest(cred_offer: any, cred_def: any, link_secret: string, link_secret_id: string): any[]; +/** +* @param {any} cred_def +* @param {any} credential +* @param {any} cred_req_meta +* @param {string} link_secret +* @returns {any} +*/ +export function proverProcessCredential(cred_def: any, credential: any, cred_req_meta: any, link_secret: string): any; +/** +* @param {any} presentation_request +* @param {any} schema_dict +* @param {any} cred_def_dict +* @param {any} credential +* @param {string} link_secret +* @returns {any} +*/ +export function proverCreatePresentation(presentation_request: any, schema_dict: any, cred_def_dict: any, credential: any, link_secret: string): any; +/** +*/ +export enum ErrorCode { + Success = 0, + Input = 1, + IOError = 2, + InvalidState = 3, + Unexpected = 4, + CredentialRevoked = 5, + InvalidUserRevocId = 6, + ProofRejected = 7, + RevocationRegistryFull = 8, +} +/** +*/ +export class BlindedCredentialSecrets { + free(): void; +} +/** +*/ +export class BlindedCredentialSecretsCorrectnessProof { + free(): void; +} +/** +*/ +export class Bls { + free(): void; +/** +*/ + constructor(); +/** +* @param {Uint8Array} message +* @param {SignKey} sign_key +* @returns {Signature} +*/ + static sign(message: Uint8Array, sign_key: SignKey): Signature; +/** +* @param {Uint8Array} message +* @param {Signature} signature +* @param {VerKey} ver_key +* @param {Generator} generator +* @returns {boolean} +*/ + static verify(message: Uint8Array, signature: Signature, ver_key: VerKey, generator: Generator): boolean; +/** +* @param {ProofOfPossession} pop +* @param {VerKey} ver_key +* @param {Generator} generator +* @returns {boolean} +*/ + static verifyProofOfPosession(pop: ProofOfPossession, ver_key: VerKey, generator: Generator): boolean; +/** +* @param {MultiSignature} multi_sig +* @param {Uint8Array} message +* @param {any[]} ver_keys +* @param {Generator} gen +* @returns {boolean} +*/ + static verifyMultiSignature(multi_sig: MultiSignature, message: Uint8Array, ver_keys: any[], gen: Generator): boolean; +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class CredentialDefinition { + free(): void; +} +/** +*/ +export class CredentialKeyCorrectnessProof { + free(): void; +} +/** +*/ +export class CredentialPrimaryPublicKey { + free(): void; +} +/** +*/ +export class CredentialPrivateKey { + free(): void; +} +/** +*/ +export class CredentialPublicKey { + free(): void; +/** +* @returns {CredentialPrimaryPublicKey} +*/ + getPrimaryKey(): CredentialPrimaryPublicKey; +/** +* @returns {any} +*/ + getRevocationKey(): any; +} +/** +*/ +export class CredentialRevocationPublicKey { + free(): void; +} +/** +*/ +export class CredentialSchema { + free(): void; +/** +*/ + constructor(); +/** +* @param {string} attribute +*/ + addAttr(attribute: string): void; +} +/** +*/ +export class CredentialSecretsBlindingFactors { + free(): void; +} +/** +*/ +export class CredentialSignature { + free(): void; +/** +* @returns {number | undefined} +*/ + extractIndex(): number | undefined; +} +/** +*/ +export class CredentialValues { + free(): void; +/** +*/ + constructor(); +/** +* @param {MasterSecret} value +*/ + addMasterSecret(value: MasterSecret): void; +/** +* @param {string} attr +* @param {string} value +*/ + addKnown(attr: string, value: string): void; +/** +* @param {string} attr +* @param {string} value +*/ + addHidden(attr: string, value: string): void; +/** +* @param {string} attr +* @param {string} value +* @param {string} blinding_factor +*/ + addCommitment(attr: string, value: string, blinding_factor: string): void; +} +/** +*/ +export class EcdhSecp256k1Sha256 { + free(): void; +/** +*/ + constructor(); +/** +* @returns {KeyPair} +*/ + keypair(): KeyPair; +/** +* @param {Uint8Array} seed +* @returns {KeyPair} +*/ + keypair_from_seed(seed: Uint8Array): KeyPair; +/** +* @param {WasmPrivateKey} sk +* @returns {WasmPublicKey} +*/ + getPublicKey(sk: WasmPrivateKey): WasmPublicKey; +/** +* @param {WasmPrivateKey} sk +* @param {WasmPublicKey} pk +* @returns {WasmSessionKey} +*/ + computeSharedSecret(sk: WasmPrivateKey, pk: WasmPublicKey): WasmSessionKey; +} +/** +*/ +export class EcdsaSecp256k1Sha256 { + free(): void; +/** +*/ + constructor(); +/** +* @returns {KeyPair} +*/ + keypair(): KeyPair; +/** +* @param {Uint8Array} seed +* @returns {KeyPair} +*/ + keypairFromSeed(seed: Uint8Array): KeyPair; +/** +* @param {WasmPrivateKey} sk +* @returns {WasmPublicKey} +*/ + getPublicKey(sk: WasmPrivateKey): WasmPublicKey; +/** +* @param {Uint8Array} message +* @param {WasmPrivateKey} sk +* @returns {Uint8Array} +*/ + sign(message: Uint8Array, sk: WasmPrivateKey): Uint8Array; +/** +* @param {Uint8Array} message +* @param {Uint8Array} signature +* @param {WasmPublicKey} pk +* @returns {boolean} +*/ + verify(message: Uint8Array, signature: Uint8Array, pk: WasmPublicKey): boolean; +/** +* @param {Uint8Array} signature +*/ + normalizeS(signature: Uint8Array): void; +/** +* @param {WasmPublicKey} pk +* @returns {WasmPublicKey} +*/ + publicKeyCompressed(pk: WasmPublicKey): WasmPublicKey; +/** +* @param {WasmPublicKey} pk +* @returns {WasmPublicKey} +*/ + publicKeyUnCompressed(pk: WasmPublicKey): WasmPublicKey; +/** +* @param {Uint8Array} bytes +* @returns {WasmPublicKey} +*/ + parseToPublicKey(bytes: Uint8Array): WasmPublicKey; +} +/** +*/ +export class Ed25519Sha512 { + free(): void; +/** +*/ + constructor(); +/** +* @param {Uint8Array} seed +* @returns {Ed25519Sha512} +*/ + static fromSeed(seed: Uint8Array): Ed25519Sha512; +/** +* @param {Uint8Array} sk +* @returns {Ed25519Sha512} +*/ + static fromPrivateKey(sk: Uint8Array): Ed25519Sha512; +/** +* @returns {Uint8Array} +*/ + getPulicKey(): Uint8Array; +/** +* @param {Uint8Array} message +* @returns {Uint8Array} +*/ + sign(message: Uint8Array): Uint8Array; +/** +* @param {Uint8Array} message +* @param {Uint8Array} signature +* @param {Uint8Array} pk +* @returns {boolean} +*/ + static verify(message: Uint8Array, signature: Uint8Array, pk: Uint8Array): boolean; +} +/** +*/ +export class Generator { + free(): void; +/** +*/ + constructor(); +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +/** +* @param {Uint8Array} bytes +* @returns {Generator} +*/ + static fromBytes(bytes: Uint8Array): Generator; +} +/** +*/ +export class IssuedCredential { + free(): void; +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class IssuedCredentialWithRevocation { + free(): void; +} +/** +*/ +export class Issuer { + free(): void; +/** +* @param {CredentialSchema} credential_schema +* @param {NonCredentialSchema} non_credential_schema +* @param {boolean} support_revocation +* @returns {CredentialDefinition} +*/ + static newCredentialDefinition(credential_schema: CredentialSchema, non_credential_schema: NonCredentialSchema, support_revocation: boolean): CredentialDefinition; +/** +* @param {string} prover_id +* @param {BlindedCredentialSecrets} blinded_credential_secrets +* @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof +* @param {Nonce} credential_nonce +* @param {Nonce} credential_issuance_nonce +* @param {CredentialValues} credential_values +* @param {CredentialPublicKey} credential_pub_key +* @param {CredentialPrivateKey} credential_priv_key +* @returns {IssuedCredential} +*/ + static signCredential(prover_id: string, blinded_credential_secrets: BlindedCredentialSecrets, blinded_credential_secrets_correctness_proof: BlindedCredentialSecretsCorrectnessProof, credential_nonce: Nonce, credential_issuance_nonce: Nonce, credential_values: CredentialValues, credential_pub_key: CredentialPublicKey, credential_priv_key: CredentialPrivateKey): IssuedCredential; +/** +* @param {string} prover_id +* @param {BlindedCredentialSecrets} blinded_credential_secrets +* @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof +* @param {Nonce} credential_nonce +* @param {Nonce} credential_issuance_nonce +* @param {CredentialValues} credential_values +* @param {CredentialPublicKey} credential_pub_key +* @param {CredentialPrivateKey} credential_priv_key +* @param {number} rev_idx +* @param {number} max_cred_num +* @param {boolean} issuance_by_default +* @param {RevocationRegistry} rev_reg +* @param {RevocationPrivateKey} rev_key_priv +* @param {SimpleTailsAccessor} rev_tails_accessor +* @returns {IssuedCredentialWithRevocation} +*/ + static signCredentialWithRevocation(prover_id: string, blinded_credential_secrets: BlindedCredentialSecrets, blinded_credential_secrets_correctness_proof: BlindedCredentialSecretsCorrectnessProof, credential_nonce: Nonce, credential_issuance_nonce: Nonce, credential_values: CredentialValues, credential_pub_key: CredentialPublicKey, credential_priv_key: CredentialPrivateKey, rev_idx: number, max_cred_num: number, issuance_by_default: boolean, rev_reg: RevocationRegistry, rev_key_priv: RevocationPrivateKey, rev_tails_accessor: SimpleTailsAccessor): IssuedCredentialWithRevocation; +} +/** +*/ +export class KeyPair { + free(): void; +} +/** +*/ +export class MasterSecret { + free(): void; +/** +*/ + constructor(); +} +/** +*/ +export class MultiSignature { + free(): void; +/** +* @param {any[]} signatures +*/ + constructor(signatures: any[]); +/** +* @param {Uint8Array} bytes +* @returns {MultiSignature} +*/ + static fromBytes(bytes: Uint8Array): MultiSignature; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class NonCredentialSchema { + free(): void; +/** +*/ + constructor(); +/** +* @param {string} attribute +*/ + addAttr(attribute: string): void; +} +/** +*/ +export class Nonce { + free(): void; +/** +*/ + constructor(); +} +/** +*/ +export class Proof { + free(): void; +} +/** +*/ +export class ProofBuilder { + free(): void; +/** +*/ + constructor(); +/** +* @param {string} attribute +*/ + addCommonAttribute(attribute: string): void; +/** +* @param {SubProofRequest} sub_proof_request +* @param {CredentialSchema} credential_schema +* @param {NonCredentialSchema} non_credential_schema +* @param {CredentialSignature} credential_signature +* @param {CredentialValues} credential_values +* @param {CredentialPublicKey} credential_pub_key +* @param {any} rev_reg +* @param {any} witness +*/ + addSubProofRequest(sub_proof_request: SubProofRequest, credential_schema: CredentialSchema, non_credential_schema: NonCredentialSchema, credential_signature: CredentialSignature, credential_values: CredentialValues, credential_pub_key: CredentialPublicKey, rev_reg: any, witness: any): void; +/** +* @param {Nonce} nonce +* @returns {Proof} +*/ + finalize(nonce: Nonce): Proof; +} +/** +*/ +export class ProofOfPossession { + free(): void; +/** +* @param {VerKey} ver_key +* @param {SignKey} sign_key +*/ + constructor(ver_key: VerKey, sign_key: SignKey); +/** +* @param {Uint8Array} bytes +* @returns {ProofOfPossession} +*/ + static fromBytes(bytes: Uint8Array): ProofOfPossession; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class ProofVerifier { + free(): void; +/** +*/ + constructor(); +/** +* @param {SubProofRequest} sub_proof_request +* @param {CredentialSchema} credential_schema +* @param {NonCredentialSchema} non_credential_schema +* @param {CredentialPublicKey} credential_pub_key +* @param {any} rev_key_pub +* @param {any} rev_reg +*/ + addSubProofRequest(sub_proof_request: SubProofRequest, credential_schema: CredentialSchema, non_credential_schema: NonCredentialSchema, credential_pub_key: CredentialPublicKey, rev_key_pub: any, rev_reg: any): void; +/** +* @param {Proof} proof +* @param {Nonce} nonce +* @returns {boolean} +*/ + verify(proof: Proof, nonce: Nonce): boolean; +} +/** +*/ +export class Prover { + free(): void; +/** +* @param {CredentialPublicKey} credential_pub_key +* @param {CredentialKeyCorrectnessProof} credential_key_correctness_proof +* @param {CredentialValues} credential_values +* @param {Nonce} credential_nonce +* @returns {ProverBlindedCredentialSecrets} +*/ + static blindedCredentialSecrets(credential_pub_key: CredentialPublicKey, credential_key_correctness_proof: CredentialKeyCorrectnessProof, credential_values: CredentialValues, credential_nonce: Nonce): ProverBlindedCredentialSecrets; +/** +* @param {IssuedCredential} issued_credential +* @param {CredentialValues} credential_values +* @param {CredentialSecretsBlindingFactors} credential_secrets_blinding_factors +* @param {CredentialPublicKey} credential_pub_key +* @param {Nonce} nonce +* @param {any} rev_key_pub +* @param {any} rev_reg +* @param {any} witness +* @returns {CredentialSignature} +*/ + static processCredentialSignature(issued_credential: IssuedCredential, credential_values: CredentialValues, credential_secrets_blinding_factors: CredentialSecretsBlindingFactors, credential_pub_key: CredentialPublicKey, nonce: Nonce, rev_key_pub: any, rev_reg: any, witness: any): CredentialSignature; +} +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +export class ProverBlindedCredentialSecrets { + free(): void; +} +/** +*/ +export class RevocationPrivateKey { + free(): void; +} +/** +*/ +export class RevocationPublicKey { + free(): void; +} +/** +*/ +export class RevocationRegistry { + free(): void; +} +/** +*/ +export class RevocationRegistryDelta { + free(): void; +/** +* @param {any} rev_reg_from +* @param {RevocationRegistry} rev_reg_to +* @param {any} issued +* @param {any} revoked +* @returns {RevocationRegistryDelta} +*/ + static fromParts(rev_reg_from: any, rev_reg_to: RevocationRegistry, issued: any, revoked: any): RevocationRegistryDelta; +/** +* @param {RevocationRegistryDelta} other_delta +*/ + merge(other_delta: RevocationRegistryDelta): void; +} +/** +*/ +export class RevocationTailsGenerator { + free(): void; +/** +* @returns {number} +*/ + count(): number; +/** +* @returns {any} +*/ + next(): any; +} +/** +*/ +export class SignKey { + free(): void; +/** +*/ + constructor(); +/** +* @param {Uint8Array} seed +* @returns {SignKey} +*/ + static fromSeed(seed: Uint8Array): SignKey; +/** +* @param {Uint8Array} bytes +* @returns {SignKey} +*/ + static fromBytes(bytes: Uint8Array): SignKey; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class Signature { + free(): void; +/** +* @param {Uint8Array} bytes +* @returns {Signature} +*/ + static fromBytes(bytes: Uint8Array): Signature; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class SignatureCorrectnessProof { + free(): void; +} +/** +*/ +export class SimpleTailsAccessor { + free(): void; +/** +* @param {RevocationTailsGenerator} rev_tails_generator +*/ + constructor(rev_tails_generator: RevocationTailsGenerator); +/** +* @param {number} tail_id +* @param {Function} accessor +*/ + accessTail(tail_id: number, accessor: Function): void; +} +/** +*/ +export class SubProofRequest { + free(): void; +/** +*/ + constructor(); +/** +* @param {string} attribute +*/ + addRevealedAttribute(attribute: string): void; +/** +* @param {string} attribute +* @param {string} p_type +* @param {number} value +*/ + addPredicate(attribute: string, p_type: string, value: number): void; +} +/** +*/ +export class Tail { + free(): void; +} +/** +*/ +export class UrsaEncryptor { + free(): void; +/** +* @param {string} cipher +* @returns {WasmCipherKey} +*/ + static new(cipher: string): WasmCipherKey; +/** +* @param {string} cipher +* @param {string} key +* @returns {WasmCipherKey} +*/ + static withKey(cipher: string, key: string): WasmCipherKey; +/** +* @param {WasmCipherKey} cipher_key +* @param {Uint8Array} aad +* @param {Uint8Array} input +* @returns {Uint8Array} +*/ + encrypt(cipher_key: WasmCipherKey, aad: Uint8Array, input: Uint8Array): Uint8Array; +/** +* @param {WasmCipherKey} cipher_key +* @param {Uint8Array} aad +* @param {Uint8Array} input +* @returns {Uint8Array} +*/ + decrypt(cipher_key: WasmCipherKey, aad: Uint8Array, input: Uint8Array): Uint8Array; +} +/** +*/ +export class VerKey { + free(): void; +/** +* @param {Generator} generator +* @param {SignKey} sign_key +*/ + constructor(generator: Generator, sign_key: SignKey); +/** +* @param {Uint8Array} bytes +* @returns {VerKey} +*/ + static fromBytes(bytes: Uint8Array): VerKey; +/** +* @returns {Uint8Array} +*/ + toBytes(): Uint8Array; +} +/** +*/ +export class WasmCipherKey { + free(): void; +} +/** +*/ +export class WasmPrivateKey { + free(): void; +} +/** +*/ +export class WasmPublicKey { + free(): void; +/** +* @param {Uint8Array} key +*/ + constructor(key: Uint8Array); +} +/** +*/ +export class WasmSessionKey { + free(): void; +} +/** +*/ +export class Witness { + free(): void; +/** +* @param {number} rev_idx +* @param {number} max_cred_num +* @param {boolean} issuance_by_default +* @param {RevocationRegistryDelta} rev_reg_delta +* @param {SimpleTailsAccessor} rev_tails_accessor +*/ + constructor(rev_idx: number, max_cred_num: number, issuance_by_default: boolean, rev_reg_delta: RevocationRegistryDelta, rev_tails_accessor: SimpleTailsAccessor); +/** +* @param {number} rev_idx +* @param {number} max_cred_num +* @param {RevocationRegistryDelta} rev_reg_delta +* @param {SimpleTailsAccessor} rev_tails_accessor +*/ + update(rev_idx: number, max_cred_num: number, rev_reg_delta: RevocationRegistryDelta, rev_tails_accessor: SimpleTailsAccessor): void; +} +/** +*/ +export class X25519Sha256 { + free(): void; +/** +*/ + constructor(); +/** +* @returns {KeyPair} +*/ + keypair(): KeyPair; +/** +* @param {Uint8Array} seed +* @returns {KeyPair} +*/ + keypair_from_seed(seed: Uint8Array): KeyPair; +/** +* @param {WasmPrivateKey} sk +* @returns {WasmPublicKey} +*/ + getPublicKey(sk: WasmPrivateKey): WasmPublicKey; +/** +* @param {WasmPrivateKey} sk +* @param {WasmPublicKey} pk +* @returns {WasmSessionKey} +*/ + computeSharedSecret(sk: WasmPrivateKey, pk: WasmPublicKey): WasmSessionKey; +} diff --git a/anoncreds-rust/node/anoncreds.js b/anoncreds-rust/node/anoncreds.js new file mode 100644 index 000000000..d64617911 --- /dev/null +++ b/anoncreds-rust/node/anoncreds.js @@ -0,0 +1,3770 @@ +let imports = {}; +imports['__wbindgen_placeholder__'] = module.exports; +let wasm; +const { TextEncoder, TextDecoder } = require(`util`); + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedFloat64Memory0 = null; + +function getFloat64Memory0() { + if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +let cachedInt32Memory0 = null; + +function getInt32Memory0() { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +let WASM_VECTOR_LEN = 0; + +let cachedUint8Memory0 = null; + +function getUint8Memory0() { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +let cachedTextEncoder = new TextEncoder('utf-8'); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length) >>> 0; + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len) >>> 0; + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0; + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedBigInt64Memory0 = null; + +function getBigInt64Memory0() { + if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) { + cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer); + } + return cachedBigInt64Memory0; +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} +/** +* @returns {number} +*/ +module.exports.anoncredsSetDefaultLogger = function() { + const ret = wasm.anoncredsSetDefaultLogger(); + return ret >>> 0; +}; + +let cachedUint32Memory0 = null; + +function getUint32Memory0() { + if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) { + cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer); + } + return cachedUint32Memory0; +} + +function passArrayJsValueToWasm0(array, malloc) { + const ptr = malloc(array.length * 4) >>> 0; + const mem = getUint32Memory0(); + for (let i = 0; i < array.length; i++) { + mem[ptr / 4 + i] = addHeapObject(array[i]); + } + WASM_VECTOR_LEN = array.length; + return ptr; +} +/** +* @param {string} name +* @param {string} version +* @param {string} issuer_id +* @param {any[]} attribute_names +* @returns {any} +*/ +module.exports.anoncredsCreateSchema = function(name, version, issuer_id, attribute_names) { + const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(issuer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + const ptr3 = passArrayJsValueToWasm0(attribute_names, wasm.__wbindgen_malloc); + const len3 = WASM_VECTOR_LEN; + const ret = wasm.anoncredsCreateSchema(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); + return takeObject(ret); +}; + +function getArrayJsValueFromWasm0(ptr, len) { + ptr = ptr >>> 0; + const mem = getUint32Memory0(); + const slice = mem.subarray(ptr / 4, ptr / 4 + len); + const result = []; + for (let i = 0; i < slice.length; i++) { + result.push(takeObject(slice[i])); + } + return result; +} +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @param {string} signature_type +* @param {boolean} support_revocation +* @returns {any[]} +*/ +module.exports.anoncredsCreateCredentialDefinition = function(schema_id, schema, tag, issuer_id, signature_type, support_revocation) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(schema_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(issuer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + const ptr3 = passStringToWasm0(signature_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len3 = WASM_VECTOR_LEN; + wasm.anoncredsCreateCredentialDefinition(retptr, ptr0, len0, addHeapObject(schema), ptr1, len1, ptr2, len2, ptr3, len3, support_revocation); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v5 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v5; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +}; + +/** +* @param {string} schema_id +* @param {any} schema +* @param {string} tag +* @param {string} issuer_id +* @returns {any[]} +*/ +module.exports.anoncredsCreateCredentialDefinitionCustom = function(schema_id, schema, tag, issuer_id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(schema_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(tag, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(issuer_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + wasm.anoncredsCreateCredentialDefinitionCustom(retptr, ptr0, len0, addHeapObject(schema), ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v4 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v4; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +}; + +/** +* @param {any} json +* @returns {boolean} +*/ +module.exports.anoncredsValidateCredentialDefinitionFromJson = function(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.anoncredsValidateCredentialDefinitionFromJson(retptr, addHeapObject(json)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +}; + +/** +* @returns {string} +*/ +module.exports.proverCreateLinkSecret = function() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.proverCreateLinkSecret(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1); + } +}; + +/** +* @param {any} cred_offer +* @param {any} cred_def +* @param {string} link_secret +* @param {string} link_secret_id +* @returns {any[]} +*/ +module.exports.proverCreateCredentialRequest = function(cred_offer, cred_def, link_secret, link_secret_id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(link_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(link_secret_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.proverCreateCredentialRequest(retptr, addHeapObject(cred_offer), addHeapObject(cred_def), ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v3 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4); + return v3; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +}; + +/** +* @param {any} cred_def +* @param {any} credential +* @param {any} cred_req_meta +* @param {string} link_secret +* @returns {any} +*/ +module.exports.proverProcessCredential = function(cred_def, credential, cred_req_meta, link_secret) { + const ptr0 = passStringToWasm0(link_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.proverProcessCredential(addHeapObject(cred_def), addHeapObject(credential), addHeapObject(cred_req_meta), ptr0, len0); + return takeObject(ret); +}; + +/** +* @param {any} presentation_request +* @param {any} schema_dict +* @param {any} cred_def_dict +* @param {any} credential +* @param {string} link_secret +* @returns {any} +*/ +module.exports.proverCreatePresentation = function(presentation_request, schema_dict, cred_def_dict, credential, link_secret) { + const ptr0 = passStringToWasm0(link_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.proverCreatePresentation(addHeapObject(presentation_request), addHeapObject(schema_dict), addHeapObject(cred_def_dict), addHeapObject(credential), ptr0, len0); + return takeObject(ret); +}; + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1) >>> 0; + getUint8Memory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} + +function _assertClass(instance, klass) { + if (!(instance instanceof klass)) { + throw new Error(`expected instance of ${klass.name}`); + } + return instance.ptr; +} + +let stack_pointer = 128; + +function addBorrowedObject(obj) { + if (stack_pointer == 1) throw new Error('out of js stack'); + heap[--stack_pointer] = obj; + return stack_pointer; +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} +/** +*/ +module.exports.ErrorCode = Object.freeze({ Success:0,"0":"Success",Input:1,"1":"Input",IOError:2,"2":"IOError",InvalidState:3,"3":"InvalidState",Unexpected:4,"4":"Unexpected",CredentialRevoked:5,"5":"CredentialRevoked",InvalidUserRevocId:6,"6":"InvalidUserRevocId",ProofRejected:7,"7":"ProofRejected",RevocationRegistryFull:8,"8":"RevocationRegistryFull", }); +/** +*/ +class BlindedCredentialSecrets { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_blindedcredentialsecrets_free(ptr); + } +} +module.exports.BlindedCredentialSecrets = BlindedCredentialSecrets; +/** +*/ +class BlindedCredentialSecretsCorrectnessProof { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_blindedcredentialsecretscorrectnessproof_free(ptr); + } +} +module.exports.BlindedCredentialSecretsCorrectnessProof = BlindedCredentialSecretsCorrectnessProof; +/** +*/ +class Bls { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Bls.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_bls_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.bls_new(); + return Bls.__wrap(ret); + } + /** + * @param {Uint8Array} message + * @param {SignKey} sign_key + * @returns {Signature} + */ + static sign(message, sign_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(sign_key, SignKey); + wasm.bls_sign(retptr, ptr0, len0, sign_key.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Signature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {Signature} signature + * @param {VerKey} ver_key + * @param {Generator} generator + * @returns {boolean} + */ + static verify(message, signature, ver_key, generator) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(signature, Signature); + _assertClass(ver_key, VerKey); + _assertClass(generator, Generator); + wasm.bls_verify(retptr, ptr0, len0, signature.__wbg_ptr, ver_key.__wbg_ptr, generator.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {ProofOfPossession} pop + * @param {VerKey} ver_key + * @param {Generator} generator + * @returns {boolean} + */ + static verifyProofOfPosession(pop, ver_key, generator) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(pop, ProofOfPossession); + _assertClass(ver_key, VerKey); + _assertClass(generator, Generator); + wasm.bls_verifyProofOfPosession(retptr, pop.__wbg_ptr, ver_key.__wbg_ptr, generator.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {MultiSignature} multi_sig + * @param {Uint8Array} message + * @param {any[]} ver_keys + * @param {Generator} gen + * @returns {boolean} + */ + static verifyMultiSignature(multi_sig, message, ver_keys, gen) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(multi_sig, MultiSignature); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArrayJsValueToWasm0(ver_keys, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(gen, Generator); + wasm.bls_verifyMultiSignature(retptr, multi_sig.__wbg_ptr, ptr0, len0, ptr1, len1, gen.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.Bls = Bls; +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +class CredentialDefinition { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialDefinition.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialdefinition_free(ptr); + } +} +module.exports.CredentialDefinition = CredentialDefinition; +/** +*/ +class CredentialKeyCorrectnessProof { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialkeycorrectnessproof_free(ptr); + } +} +module.exports.CredentialKeyCorrectnessProof = CredentialKeyCorrectnessProof; +/** +*/ +class CredentialPrimaryPublicKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialPrimaryPublicKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialprimarypublickey_free(ptr); + } +} +module.exports.CredentialPrimaryPublicKey = CredentialPrimaryPublicKey; +/** +*/ +class CredentialPrivateKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialprivatekey_free(ptr); + } +} +module.exports.CredentialPrivateKey = CredentialPrivateKey; +/** +*/ +class CredentialPublicKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialpublickey_free(ptr); + } + /** + * @returns {CredentialPrimaryPublicKey} + */ + getPrimaryKey() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credentialpublickey_getPrimaryKey(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return CredentialPrimaryPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {any} + */ + getRevocationKey() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credentialpublickey_getRevocationKey(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.CredentialPublicKey = CredentialPublicKey; +/** +*/ +class CredentialRevocationPublicKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialrevocationpublickey_free(ptr); + } +} +module.exports.CredentialRevocationPublicKey = CredentialRevocationPublicKey; +/** +*/ +class CredentialSchema { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialSchema.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialschema_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.credentialschema_new(); + return CredentialSchema.__wrap(ret); + } + /** + * @param {string} attribute + */ + addAttr(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.credentialschema_addAttr(this.__wbg_ptr, ptr0, len0); + } +} +module.exports.CredentialSchema = CredentialSchema; +/** +*/ +class CredentialSecretsBlindingFactors { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialsecretsblindingfactors_free(ptr); + } +} +module.exports.CredentialSecretsBlindingFactors = CredentialSecretsBlindingFactors; +/** +*/ +class CredentialSignature { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialSignature.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialsignature_free(ptr); + } + /** + * @returns {number | undefined} + */ + extractIndex() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credentialsignature_extractIndex(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + return r0 === 0 ? undefined : r1 >>> 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.CredentialSignature = CredentialSignature; +/** +*/ +class CredentialValues { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CredentialValues.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credentialvalues_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.credentialschema_new(); + return CredentialValues.__wrap(ret); + } + /** + * @param {MasterSecret} value + */ + addMasterSecret(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(value, MasterSecret); + wasm.credentialvalues_addMasterSecret(retptr, this.__wbg_ptr, value.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} attr + * @param {string} value + */ + addKnown(attr, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.credentialvalues_addKnown(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} attr + * @param {string} value + */ + addHidden(attr, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.credentialvalues_addHidden(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} attr + * @param {string} value + * @param {string} blinding_factor + */ + addCommitment(attr, value, blinding_factor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(attr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(blinding_factor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + wasm.credentialvalues_addCommitment(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.CredentialValues = CredentialValues; +/** +*/ +class EcdhSecp256k1Sha256 { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(EcdhSecp256k1Sha256.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ecdhsecp256k1sha256_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.ecdsasecp256k1sha256_new(); + return EcdhSecp256k1Sha256.__wrap(ret); + } + /** + * @returns {KeyPair} + */ + keypair() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ecdhsecp256k1sha256_keypair(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {KeyPair} + */ + keypair_from_seed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ecdhsecp256k1sha256_keypair_from_seed(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @returns {WasmPublicKey} + */ + getPublicKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + wasm.ecdhsecp256k1sha256_getPublicKey(retptr, this.__wbg_ptr, sk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @param {WasmPublicKey} pk + * @returns {WasmSessionKey} + */ + computeSharedSecret(sk, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + _assertClass(pk, WasmPublicKey); + wasm.ecdhsecp256k1sha256_computeSharedSecret(retptr, this.__wbg_ptr, sk.__wbg_ptr, pk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmSessionKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.EcdhSecp256k1Sha256 = EcdhSecp256k1Sha256; +/** +*/ +class EcdsaSecp256k1Sha256 { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(EcdsaSecp256k1Sha256.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ecdsasecp256k1sha256_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.ecdsasecp256k1sha256_new(); + return EcdsaSecp256k1Sha256.__wrap(ret); + } + /** + * @returns {KeyPair} + */ + keypair() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ecdsasecp256k1sha256_keypair(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {KeyPair} + */ + keypairFromSeed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ecdsasecp256k1sha256_keypairFromSeed(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @returns {WasmPublicKey} + */ + getPublicKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + wasm.ecdsasecp256k1sha256_getPublicKey(retptr, this.__wbg_ptr, sk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {WasmPrivateKey} sk + * @returns {Uint8Array} + */ + sign(message, sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(sk, WasmPrivateKey); + wasm.ecdsasecp256k1sha256_sign(retptr, this.__wbg_ptr, ptr0, len0, sk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v2 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v2; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {Uint8Array} signature + * @param {WasmPublicKey} pk + * @returns {boolean} + */ + verify(message, signature, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(pk, WasmPublicKey); + wasm.ecdsasecp256k1sha256_verify(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, pk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} signature + */ + normalizeS(signature) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + var ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.ecdsasecp256k1sha256_normalizeS(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(signature)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPublicKey} pk + * @returns {WasmPublicKey} + */ + publicKeyCompressed(pk) { + _assertClass(pk, WasmPublicKey); + const ret = wasm.ecdsasecp256k1sha256_publicKeyCompressed(this.__wbg_ptr, pk.__wbg_ptr); + return WasmPublicKey.__wrap(ret); + } + /** + * @param {WasmPublicKey} pk + * @returns {WasmPublicKey} + */ + publicKeyUnCompressed(pk) { + _assertClass(pk, WasmPublicKey); + const ret = wasm.ecdsasecp256k1sha256_publicKeyUnCompressed(this.__wbg_ptr, pk.__wbg_ptr); + return WasmPublicKey.__wrap(ret); + } + /** + * @param {Uint8Array} bytes + * @returns {WasmPublicKey} + */ + parseToPublicKey(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ecdsasecp256k1sha256_parseToPublicKey(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.EcdsaSecp256k1Sha256 = EcdsaSecp256k1Sha256; +/** +*/ +class Ed25519Sha512 { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Ed25519Sha512.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ed25519sha512_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ed25519sha512_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Ed25519Sha512.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {Ed25519Sha512} + */ + static fromSeed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ed25519sha512_fromSeed(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Ed25519Sha512.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} sk + * @returns {Ed25519Sha512} + */ + static fromPrivateKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(sk, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ed25519sha512_fromPrivateKey(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Ed25519Sha512.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + getPulicKey() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.ed25519sha512_getPulicKey(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @returns {Uint8Array} + */ + sign(message) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.ed25519sha512_sign(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v2 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v2; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} message + * @param {Uint8Array} signature + * @param {Uint8Array} pk + * @returns {boolean} + */ + static verify(message, signature, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(pk, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + wasm.ed25519sha512_verify(retptr, ptr0, len0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.Ed25519Sha512 = Ed25519Sha512; +/** +*/ +class Generator { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Generator.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_generator_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.generator_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Generator.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.generator_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {Generator} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.generator_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Generator.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.Generator = Generator; +/** +*/ +class IssuedCredential { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(IssuedCredential.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuedcredential_free(ptr); + } +} +module.exports.IssuedCredential = IssuedCredential; +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +class IssuedCredentialWithRevocation { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(IssuedCredentialWithRevocation.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuedcredentialwithrevocation_free(ptr); + } +} +module.exports.IssuedCredentialWithRevocation = IssuedCredentialWithRevocation; +/** +*/ +class Issuer { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuer_free(ptr); + } + /** + * @param {CredentialSchema} credential_schema + * @param {NonCredentialSchema} non_credential_schema + * @param {boolean} support_revocation + * @returns {CredentialDefinition} + */ + static newCredentialDefinition(credential_schema, non_credential_schema, support_revocation) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential_schema, CredentialSchema); + var ptr0 = credential_schema.__destroy_into_raw(); + _assertClass(non_credential_schema, NonCredentialSchema); + var ptr1 = non_credential_schema.__destroy_into_raw(); + wasm.issuer_newCredentialDefinition(retptr, ptr0, ptr1, support_revocation); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return CredentialDefinition.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} prover_id + * @param {BlindedCredentialSecrets} blinded_credential_secrets + * @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof + * @param {Nonce} credential_nonce + * @param {Nonce} credential_issuance_nonce + * @param {CredentialValues} credential_values + * @param {CredentialPublicKey} credential_pub_key + * @param {CredentialPrivateKey} credential_priv_key + * @returns {IssuedCredential} + */ + static signCredential(prover_id, blinded_credential_secrets, blinded_credential_secrets_correctness_proof, credential_nonce, credential_issuance_nonce, credential_values, credential_pub_key, credential_priv_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(prover_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(blinded_credential_secrets, BlindedCredentialSecrets); + _assertClass(blinded_credential_secrets_correctness_proof, BlindedCredentialSecretsCorrectnessProof); + _assertClass(credential_nonce, Nonce); + _assertClass(credential_issuance_nonce, Nonce); + _assertClass(credential_values, CredentialValues); + var ptr1 = credential_values.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(credential_priv_key, CredentialPrivateKey); + wasm.issuer_signCredential(retptr, ptr0, len0, blinded_credential_secrets.__wbg_ptr, blinded_credential_secrets_correctness_proof.__wbg_ptr, credential_nonce.__wbg_ptr, credential_issuance_nonce.__wbg_ptr, ptr1, credential_pub_key.__wbg_ptr, credential_priv_key.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return IssuedCredential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} prover_id + * @param {BlindedCredentialSecrets} blinded_credential_secrets + * @param {BlindedCredentialSecretsCorrectnessProof} blinded_credential_secrets_correctness_proof + * @param {Nonce} credential_nonce + * @param {Nonce} credential_issuance_nonce + * @param {CredentialValues} credential_values + * @param {CredentialPublicKey} credential_pub_key + * @param {CredentialPrivateKey} credential_priv_key + * @param {number} rev_idx + * @param {number} max_cred_num + * @param {boolean} issuance_by_default + * @param {RevocationRegistry} rev_reg + * @param {RevocationPrivateKey} rev_key_priv + * @param {SimpleTailsAccessor} rev_tails_accessor + * @returns {IssuedCredentialWithRevocation} + */ + static signCredentialWithRevocation(prover_id, blinded_credential_secrets, blinded_credential_secrets_correctness_proof, credential_nonce, credential_issuance_nonce, credential_values, credential_pub_key, credential_priv_key, rev_idx, max_cred_num, issuance_by_default, rev_reg, rev_key_priv, rev_tails_accessor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(prover_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(blinded_credential_secrets, BlindedCredentialSecrets); + _assertClass(blinded_credential_secrets_correctness_proof, BlindedCredentialSecretsCorrectnessProof); + _assertClass(credential_nonce, Nonce); + _assertClass(credential_issuance_nonce, Nonce); + _assertClass(credential_values, CredentialValues); + var ptr1 = credential_values.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(credential_priv_key, CredentialPrivateKey); + _assertClass(rev_reg, RevocationRegistry); + _assertClass(rev_key_priv, RevocationPrivateKey); + _assertClass(rev_tails_accessor, SimpleTailsAccessor); + wasm.issuer_signCredentialWithRevocation(retptr, ptr0, len0, blinded_credential_secrets.__wbg_ptr, blinded_credential_secrets_correctness_proof.__wbg_ptr, credential_nonce.__wbg_ptr, credential_issuance_nonce.__wbg_ptr, ptr1, credential_pub_key.__wbg_ptr, credential_priv_key.__wbg_ptr, rev_idx, max_cred_num, issuance_by_default, rev_reg.__wbg_ptr, rev_key_priv.__wbg_ptr, rev_tails_accessor.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return IssuedCredentialWithRevocation.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.Issuer = Issuer; +/** +*/ +class KeyPair { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(KeyPair.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_keypair_free(ptr); + } +} +module.exports.KeyPair = KeyPair; +/** +*/ +class MasterSecret { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(MasterSecret.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_mastersecret_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.mastersecret_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MasterSecret.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.MasterSecret = MasterSecret; +/** +*/ +class MultiSignature { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(MultiSignature.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_multisignature_free(ptr); + } + /** + * @param {any[]} signatures + */ + constructor(signatures) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArrayJsValueToWasm0(signatures, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_new(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MultiSignature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {MultiSignature} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MultiSignature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.multisignature_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.MultiSignature = MultiSignature; +/** +*/ +class NonCredentialSchema { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(NonCredentialSchema.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_noncredentialschema_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.credentialschema_new(); + return NonCredentialSchema.__wrap(ret); + } + /** + * @param {string} attribute + */ + addAttr(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.credentialschema_addAttr(this.__wbg_ptr, ptr0, len0); + } +} +module.exports.NonCredentialSchema = NonCredentialSchema; +/** +*/ +class Nonce { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Nonce.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_nonce_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.nonce_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Nonce.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.Nonce = Nonce; +/** +*/ +class Proof { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Proof.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proof_free(ptr); + } +} +module.exports.Proof = Proof; +/** +*/ +class ProofBuilder { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(ProofBuilder.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofbuilder_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.proofbuilder_new(); + return ProofBuilder.__wrap(ret); + } + /** + * @param {string} attribute + */ + addCommonAttribute(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.proofbuilder_addCommonAttribute(this.__wbg_ptr, ptr0, len0); + } + /** + * @param {SubProofRequest} sub_proof_request + * @param {CredentialSchema} credential_schema + * @param {NonCredentialSchema} non_credential_schema + * @param {CredentialSignature} credential_signature + * @param {CredentialValues} credential_values + * @param {CredentialPublicKey} credential_pub_key + * @param {any} rev_reg + * @param {any} witness + */ + addSubProofRequest(sub_proof_request, credential_schema, non_credential_schema, credential_signature, credential_values, credential_pub_key, rev_reg, witness) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sub_proof_request, SubProofRequest); + var ptr0 = sub_proof_request.__destroy_into_raw(); + _assertClass(credential_schema, CredentialSchema); + var ptr1 = credential_schema.__destroy_into_raw(); + _assertClass(non_credential_schema, NonCredentialSchema); + var ptr2 = non_credential_schema.__destroy_into_raw(); + _assertClass(credential_signature, CredentialSignature); + _assertClass(credential_values, CredentialValues); + var ptr3 = credential_values.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + wasm.proofbuilder_addSubProofRequest(retptr, this.__wbg_ptr, ptr0, ptr1, ptr2, credential_signature.__wbg_ptr, ptr3, credential_pub_key.__wbg_ptr, addBorrowedObject(rev_reg), addBorrowedObject(witness)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * @param {Nonce} nonce + * @returns {Proof} + */ + finalize(nonce) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(nonce, Nonce); + wasm.proofbuilder_finalize(retptr, this.__wbg_ptr, nonce.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Proof.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.ProofBuilder = ProofBuilder; +/** +*/ +class ProofOfPossession { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(ProofOfPossession.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofofpossession_free(ptr); + } + /** + * @param {VerKey} ver_key + * @param {SignKey} sign_key + */ + constructor(ver_key, sign_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(ver_key, VerKey); + _assertClass(sign_key, SignKey); + wasm.proofofpossession_new(retptr, ver_key.__wbg_ptr, sign_key.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return ProofOfPossession.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {ProofOfPossession} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return ProofOfPossession.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.multisignature_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.ProofOfPossession = ProofOfPossession; +/** +*/ +class ProofVerifier { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(ProofVerifier.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofverifier_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.proofverifier_new(); + return ProofVerifier.__wrap(ret); + } + /** + * @param {SubProofRequest} sub_proof_request + * @param {CredentialSchema} credential_schema + * @param {NonCredentialSchema} non_credential_schema + * @param {CredentialPublicKey} credential_pub_key + * @param {any} rev_key_pub + * @param {any} rev_reg + */ + addSubProofRequest(sub_proof_request, credential_schema, non_credential_schema, credential_pub_key, rev_key_pub, rev_reg) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sub_proof_request, SubProofRequest); + var ptr0 = sub_proof_request.__destroy_into_raw(); + _assertClass(credential_schema, CredentialSchema); + var ptr1 = credential_schema.__destroy_into_raw(); + _assertClass(non_credential_schema, NonCredentialSchema); + var ptr2 = non_credential_schema.__destroy_into_raw(); + _assertClass(credential_pub_key, CredentialPublicKey); + wasm.proofverifier_addSubProofRequest(retptr, this.__wbg_ptr, ptr0, ptr1, ptr2, credential_pub_key.__wbg_ptr, addBorrowedObject(rev_key_pub), addBorrowedObject(rev_reg)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * @param {Proof} proof + * @param {Nonce} nonce + * @returns {boolean} + */ + verify(proof, nonce) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(proof, Proof); + _assertClass(nonce, Nonce); + wasm.proofverifier_verify(retptr, this.__wbg_ptr, proof.__wbg_ptr, nonce.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.ProofVerifier = ProofVerifier; +/** +*/ +class Prover { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_prover_free(ptr); + } + /** + * @param {CredentialPublicKey} credential_pub_key + * @param {CredentialKeyCorrectnessProof} credential_key_correctness_proof + * @param {CredentialValues} credential_values + * @param {Nonce} credential_nonce + * @returns {ProverBlindedCredentialSecrets} + */ + static blindedCredentialSecrets(credential_pub_key, credential_key_correctness_proof, credential_values, credential_nonce) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(credential_key_correctness_proof, CredentialKeyCorrectnessProof); + _assertClass(credential_values, CredentialValues); + var ptr0 = credential_values.__destroy_into_raw(); + _assertClass(credential_nonce, Nonce); + wasm.prover_blindedCredentialSecrets(retptr, credential_pub_key.__wbg_ptr, credential_key_correctness_proof.__wbg_ptr, ptr0, credential_nonce.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return ProverBlindedCredentialSecrets.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {IssuedCredential} issued_credential + * @param {CredentialValues} credential_values + * @param {CredentialSecretsBlindingFactors} credential_secrets_blinding_factors + * @param {CredentialPublicKey} credential_pub_key + * @param {Nonce} nonce + * @param {any} rev_key_pub + * @param {any} rev_reg + * @param {any} witness + * @returns {CredentialSignature} + */ + static processCredentialSignature(issued_credential, credential_values, credential_secrets_blinding_factors, credential_pub_key, nonce, rev_key_pub, rev_reg, witness) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(issued_credential, IssuedCredential); + _assertClass(credential_values, CredentialValues); + var ptr0 = credential_values.__destroy_into_raw(); + _assertClass(credential_secrets_blinding_factors, CredentialSecretsBlindingFactors); + _assertClass(credential_pub_key, CredentialPublicKey); + _assertClass(nonce, Nonce); + wasm.prover_processCredentialSignature(retptr, issued_credential.__wbg_ptr, ptr0, credential_secrets_blinding_factors.__wbg_ptr, credential_pub_key.__wbg_ptr, nonce.__wbg_ptr, addBorrowedObject(rev_key_pub), addBorrowedObject(rev_reg), addBorrowedObject(witness)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return CredentialSignature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } +} +module.exports.Prover = Prover; +/** +* Convenience class for javascript. This provides a name-value pair structure +* instead of a tuple. The compiler complains about unused fields +* so allow(unused) is in place for now +*/ +class ProverBlindedCredentialSecrets { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(ProverBlindedCredentialSecrets.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proverblindedcredentialsecrets_free(ptr); + } +} +module.exports.ProverBlindedCredentialSecrets = ProverBlindedCredentialSecrets; +/** +*/ +class RevocationPrivateKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationprivatekey_free(ptr); + } +} +module.exports.RevocationPrivateKey = RevocationPrivateKey; +/** +*/ +class RevocationPublicKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationpublickey_free(ptr); + } +} +module.exports.RevocationPublicKey = RevocationPublicKey; +/** +*/ +class RevocationRegistry { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationregistry_free(ptr); + } +} +module.exports.RevocationRegistry = RevocationRegistry; +/** +*/ +class RevocationRegistryDelta { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(RevocationRegistryDelta.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationregistrydelta_free(ptr); + } + /** + * @param {any} rev_reg_from + * @param {RevocationRegistry} rev_reg_to + * @param {any} issued + * @param {any} revoked + * @returns {RevocationRegistryDelta} + */ + static fromParts(rev_reg_from, rev_reg_to, issued, revoked) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_reg_to, RevocationRegistry); + wasm.revocationregistrydelta_fromParts(retptr, addBorrowedObject(rev_reg_from), rev_reg_to.__wbg_ptr, addBorrowedObject(issued), addBorrowedObject(revoked)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return RevocationRegistryDelta.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * @param {RevocationRegistryDelta} other_delta + */ + merge(other_delta) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(other_delta, RevocationRegistryDelta); + wasm.revocationregistrydelta_merge(retptr, this.__wbg_ptr, other_delta.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.RevocationRegistryDelta = RevocationRegistryDelta; +/** +*/ +class RevocationTailsGenerator { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationtailsgenerator_free(ptr); + } + /** + * @returns {number} + */ + count() { + const ret = wasm.revocationtailsgenerator_count(this.__wbg_ptr); + return ret >>> 0; + } + /** + * @returns {any} + */ + next() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.revocationtailsgenerator_next(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.RevocationTailsGenerator = RevocationTailsGenerator; +/** +*/ +class SignKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(SignKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_signkey_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.signkey_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SignKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {SignKey} + */ + static fromSeed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.signkey_fromSeed(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SignKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {SignKey} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.signkey_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SignKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.signkey_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.SignKey = SignKey; +/** +*/ +class Signature { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Signature.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_signature_free(ptr); + } + /** + * @param {Uint8Array} bytes + * @returns {Signature} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.multisignature_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Signature.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.multisignature_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.Signature = Signature; +/** +*/ +class SignatureCorrectnessProof { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_signaturecorrectnessproof_free(ptr); + } +} +module.exports.SignatureCorrectnessProof = SignatureCorrectnessProof; +/** +*/ +class SimpleTailsAccessor { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(SimpleTailsAccessor.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_simpletailsaccessor_free(ptr); + } + /** + * @param {RevocationTailsGenerator} rev_tails_generator + */ + constructor(rev_tails_generator) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_tails_generator, RevocationTailsGenerator); + wasm.simpletailsaccessor_new(retptr, rev_tails_generator.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return SimpleTailsAccessor.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {number} tail_id + * @param {Function} accessor + */ + accessTail(tail_id, accessor) { + try { + wasm.simpletailsaccessor_accessTail(this.__wbg_ptr, tail_id, addBorrowedObject(accessor)); + } finally { + heap[stack_pointer++] = undefined; + } + } +} +module.exports.SimpleTailsAccessor = SimpleTailsAccessor; +/** +*/ +class SubProofRequest { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(SubProofRequest.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_subproofrequest_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.subproofrequest_new(); + return SubProofRequest.__wrap(ret); + } + /** + * @param {string} attribute + */ + addRevealedAttribute(attribute) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.credentialschema_addAttr(this.__wbg_ptr, ptr0, len0); + } + /** + * @param {string} attribute + * @param {string} p_type + * @param {number} value + */ + addPredicate(attribute, p_type, value) { + const ptr0 = passStringToWasm0(attribute, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(p_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.subproofrequest_addPredicate(this.__wbg_ptr, ptr0, len0, ptr1, len1, value); + } +} +module.exports.SubProofRequest = SubProofRequest; +/** +*/ +class Tail { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_tail_free(ptr); + } +} +module.exports.Tail = Tail; +/** +*/ +class UrsaEncryptor { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_ursaencryptor_free(ptr); + } + /** + * @param {string} cipher + * @returns {WasmCipherKey} + */ + static new(cipher) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(cipher, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.ursaencryptor_new(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmCipherKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} cipher + * @param {string} key + * @returns {WasmCipherKey} + */ + static withKey(cipher, key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(cipher, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.ursaencryptor_withKey(retptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmCipherKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmCipherKey} cipher_key + * @param {Uint8Array} aad + * @param {Uint8Array} input + * @returns {Uint8Array} + */ + encrypt(cipher_key, aad, input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(cipher_key, WasmCipherKey); + var ptr0 = cipher_key.__destroy_into_raw(); + const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(input, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + wasm.ursaencryptor_encrypt(retptr, this.__wbg_ptr, ptr0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v4 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v4; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmCipherKey} cipher_key + * @param {Uint8Array} aad + * @param {Uint8Array} input + * @returns {Uint8Array} + */ + decrypt(cipher_key, aad, input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(cipher_key, WasmCipherKey); + var ptr0 = cipher_key.__destroy_into_raw(); + const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(input, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + wasm.ursaencryptor_decrypt(retptr, this.__wbg_ptr, ptr0, ptr1, len1, ptr2, len2); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v4 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v4; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.UrsaEncryptor = UrsaEncryptor; +/** +*/ +class VerKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(VerKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_verkey_free(ptr); + } + /** + * @param {Generator} generator + * @param {SignKey} sign_key + */ + constructor(generator, sign_key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(generator, Generator); + var ptr0 = generator.__destroy_into_raw(); + _assertClass(sign_key, SignKey); + var ptr1 = sign_key.__destroy_into_raw(); + wasm.verkey_new(retptr, ptr0, ptr1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return VerKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} bytes + * @returns {VerKey} + */ + static fromBytes(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.verkey_fromBytes(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return VerKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + toBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.verkey_toBytes(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.VerKey = VerKey; +/** +*/ +class WasmCipherKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(WasmCipherKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmcipherkey_free(ptr); + } +} +module.exports.WasmCipherKey = WasmCipherKey; +/** +*/ +class WasmPrivateKey { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmprivatekey_free(ptr); + } +} +module.exports.WasmPrivateKey = WasmPrivateKey; +/** +*/ +class WasmPublicKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(WasmPublicKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmpublickey_free(ptr); + } + /** + * @param {Uint8Array} key + */ + constructor(key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.wasmpublickey_new(retptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.WasmPublicKey = WasmPublicKey; +/** +*/ +class WasmSessionKey { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(WasmSessionKey.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmsessionkey_free(ptr); + } +} +module.exports.WasmSessionKey = WasmSessionKey; +/** +*/ +class Witness { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Witness.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_witness_free(ptr); + } + /** + * @param {number} rev_idx + * @param {number} max_cred_num + * @param {boolean} issuance_by_default + * @param {RevocationRegistryDelta} rev_reg_delta + * @param {SimpleTailsAccessor} rev_tails_accessor + */ + constructor(rev_idx, max_cred_num, issuance_by_default, rev_reg_delta, rev_tails_accessor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_reg_delta, RevocationRegistryDelta); + _assertClass(rev_tails_accessor, SimpleTailsAccessor); + wasm.witness_new(retptr, rev_idx, max_cred_num, issuance_by_default, rev_reg_delta.__wbg_ptr, rev_tails_accessor.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return Witness.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {number} rev_idx + * @param {number} max_cred_num + * @param {RevocationRegistryDelta} rev_reg_delta + * @param {SimpleTailsAccessor} rev_tails_accessor + */ + update(rev_idx, max_cred_num, rev_reg_delta, rev_tails_accessor) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(rev_reg_delta, RevocationRegistryDelta); + _assertClass(rev_tails_accessor, SimpleTailsAccessor); + wasm.witness_update(retptr, this.__wbg_ptr, rev_idx, max_cred_num, rev_reg_delta.__wbg_ptr, rev_tails_accessor.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.Witness = Witness; +/** +*/ +class X25519Sha256 { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(X25519Sha256.prototype); + obj.__wbg_ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_x25519sha256_free(ptr); + } + /** + */ + constructor() { + const ret = wasm.ecdsasecp256k1sha256_new(); + return X25519Sha256.__wrap(ret); + } + /** + * @returns {KeyPair} + */ + keypair() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.x25519sha256_keypair(retptr, this.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Uint8Array} seed + * @returns {KeyPair} + */ + keypair_from_seed(seed) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.x25519sha256_keypair_from_seed(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return KeyPair.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @returns {WasmPublicKey} + */ + getPublicKey(sk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + wasm.x25519sha256_getPublicKey(retptr, this.__wbg_ptr, sk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmPublicKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WasmPrivateKey} sk + * @param {WasmPublicKey} pk + * @returns {WasmSessionKey} + */ + computeSharedSecret(sk, pk) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sk, WasmPrivateKey); + _assertClass(pk, WasmPublicKey); + wasm.x25519sha256_computeSharedSecret(retptr, this.__wbg_ptr, sk.__wbg_ptr, pk.__wbg_ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WasmSessionKey.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.X25519Sha256 = X25519Sha256; + +module.exports.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; +}; + +module.exports.__wbindgen_is_bigint = function(arg0) { + const ret = typeof(getObject(arg0)) === 'bigint'; + return ret; +}; + +module.exports.__wbindgen_bigint_from_i64 = function(arg0) { + const ret = arg0; + return addHeapObject(ret); +}; + +module.exports.__wbindgen_jsval_eq = function(arg0, arg1) { + const ret = getObject(arg0) === getObject(arg1); + return ret; +}; + +module.exports.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); +}; + +module.exports.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); +}; + +module.exports.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; +}; + +module.exports.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; +}; + +module.exports.__wbindgen_in = function(arg0, arg1) { + const ret = getObject(arg0) in getObject(arg1); + return ret; +}; + +module.exports.__wbindgen_bigint_from_u64 = function(arg0) { + const ret = BigInt.asUintN(64, arg0); + return addHeapObject(ret); +}; + +module.exports.__wbindgen_error_new = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbindgen_is_string = function(arg0) { + const ret = typeof(getObject(arg0)) === 'string'; + return ret; +}; + +module.exports.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; +}; + +module.exports.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); +}; + +module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) { + const ret = getObject(arg0) == getObject(arg1); + return ret; +}; + +module.exports.__wbindgen_number_new = function(arg0) { + const ret = arg0; + return addHeapObject(ret); +}; + +module.exports.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) { + const ret = getObject(arg0)[getObject(arg1)]; + return addHeapObject(ret); +}; + +module.exports.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); +}; + +module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) { + console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +module.exports.__wbg_error_a7e23606158b68b9 = function(arg0) { + console.error(getObject(arg0)); +}; + +module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) { + console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) { + console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +module.exports.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) { + console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) { + console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3)); +}; + +module.exports.__wbindgen_json_parse = function(arg0, arg1) { + const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbindgen_json_serialize = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = JSON.stringify(obj === undefined ? null : obj); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; +}; + +module.exports.__wbindgen_is_null = function(arg0) { + const ret = getObject(arg0) === null; + return ret; +}; + +module.exports.__wbindgen_copy_to_typed_array = function(arg0, arg1, arg2) { + new Uint8Array(getObject(arg2).buffer, getObject(arg2).byteOffset, getObject(arg2).byteLength).set(getArrayU8FromWasm0(arg0, arg1)); +}; + +module.exports.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); +}, arguments) }; + +module.exports.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) { + getObject(arg0).randomFillSync(takeObject(arg1)); +}, arguments) }; + +module.exports.__wbg_crypto_c48a774b022d20ac = function(arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); +}; + +module.exports.__wbg_process_298734cf255a885d = function(arg0) { + const ret = getObject(arg0).process; + return addHeapObject(ret); +}; + +module.exports.__wbg_versions_e2e78e134e3e5d01 = function(arg0) { + const ret = getObject(arg0).versions; + return addHeapObject(ret); +}; + +module.exports.__wbg_node_1cd7a5d853dbea79 = function(arg0) { + const ret = getObject(arg0).node; + return addHeapObject(ret); +}; + +module.exports.__wbg_msCrypto_bcb970640f50a1e8 = function(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); +}; + +module.exports.__wbg_require_8f08ceecec0f4fee = function() { return handleError(function () { + const ret = module.require; + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; +}; + +module.exports.__wbg_self_7eede1f4488bf346 = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbg_crypto_c909fb428dcbddb6 = function(arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); +}; + +module.exports.__wbg_msCrypto_511eefefbfc70ae4 = function(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); +}; + +module.exports.__wbg_static_accessor_MODULE_ef3aa2eb251158a5 = function() { + const ret = module; + return addHeapObject(ret); +}; + +module.exports.__wbg_require_900d5c3984fe7703 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); +}; + +module.exports.__wbg_getRandomValues_307049345d0bd88c = function(arg0) { + const ret = getObject(arg0).getRandomValues; + return addHeapObject(ret); +}; + +module.exports.__wbg_getRandomValues_cd175915511f705e = function(arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); +}; + +module.exports.__wbg_randomFillSync_85b3f4c52c56c313 = function(arg0, arg1, arg2) { + getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2)); +}; + +module.exports.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) { + const ret = getObject(arg0)[arg1 >>> 0]; + return addHeapObject(ret); +}; + +module.exports.__wbg_length_820c786973abdd8a = function(arg0) { + const ret = getObject(arg0).length; + return ret; +}; + +module.exports.__wbg_new_0394642eae39db16 = function() { + const ret = new Array(); + return addHeapObject(ret); +}; + +module.exports.__wbg_newnoargs_c9e6043b8ad84109 = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbg_new_0f2b71ca2f2a6029 = function() { + const ret = new Map(); + return addHeapObject(ret); +}; + +module.exports.__wbg_next_f4bc0e96ea67da68 = function(arg0) { + const ret = getObject(arg0).next; + return addHeapObject(ret); +}; + +module.exports.__wbg_next_ec061e48a0e72a96 = function() { return handleError(function (arg0) { + const ret = getObject(arg0).next(); + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbg_done_b6abb27d42b63867 = function(arg0) { + const ret = getObject(arg0).done; + return ret; +}; + +module.exports.__wbg_value_2f4ef2036bfad28e = function(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); +}; + +module.exports.__wbg_iterator_7c7e58f62eb84700 = function() { + const ret = Symbol.iterator; + return addHeapObject(ret); +}; + +module.exports.__wbg_get_f53c921291c381bd = function() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(getObject(arg0), getObject(arg1)); + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbg_call_557a2f2deacc4912 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbg_new_2b6fea4ea03b1b95 = function() { + const ret = new Object(); + return addHeapObject(ret); +}; + +module.exports.__wbg_set_b4da98d504ac6091 = function(arg0, arg1, arg2) { + getObject(arg0)[arg1 >>> 0] = takeObject(arg2); +}; + +module.exports.__wbg_isArray_04e59fb73f78ab5b = function(arg0) { + const ret = Array.isArray(getObject(arg0)); + return ret; +}; + +module.exports.__wbg_instanceof_ArrayBuffer_ef2632aa0d4bfff8 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof ArrayBuffer; + } catch { + result = false; + } + const ret = result; + return ret; +}; + +module.exports.__wbg_call_587b30eea3e09332 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbg_set_da7be7bf0e037b14 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).set(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); +}; + +module.exports.__wbg_isSafeInteger_2088b01008075470 = function(arg0) { + const ret = Number.isSafeInteger(getObject(arg0)); + return ret; +}; + +module.exports.__wbg_entries_13e011453776468f = function(arg0) { + const ret = Object.entries(getObject(arg0)); + return addHeapObject(ret); +}; + +module.exports.__wbg_buffer_55ba7a6b1b92e2ac = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); +}; + +module.exports.__wbg_self_742dd6eab3e9211e = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbg_window_c409e731db53a0e2 = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbg_globalThis_b70c095388441f2d = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbg_global_1c72617491ed7194 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); +}, arguments) }; + +module.exports.__wbg_newwithbyteoffsetandlength_88d1d8be5df94b9b = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); +}; + +module.exports.__wbg_new_09938a7d020f049b = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); +}; + +module.exports.__wbg_set_3698e3ca519b3c3c = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); +}; + +module.exports.__wbg_length_0aab7ffd65ad19ed = function(arg0) { + const ret = getObject(arg0).length; + return ret; +}; + +module.exports.__wbg_instanceof_Uint8Array_1349640af2da2e88 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Uint8Array; + } catch { + result = false; + } + const ret = result; + return ret; +}; + +module.exports.__wbg_newwithlength_89eeca401d8918c2 = function(arg0) { + const ret = new Uint8Array(arg0 >>> 0); + return addHeapObject(ret); +}; + +module.exports.__wbg_subarray_d82be056deb4ad27 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); +}; + +module.exports.__wbg_new_abda76e883ba8a5f = function() { + const ret = new Error(); + return addHeapObject(ret); +}; + +module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; +}; + +module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1); + } +}; + +module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) { + const v = getObject(arg1); + const ret = typeof(v) === 'bigint' ? v : undefined; + getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); +}; + +module.exports.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; +}; + +module.exports.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); +}; + +module.exports.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); +}; + +const path = require('path').join(__dirname, 'anoncreds_bg.wasm'); +const bytes = require('fs').readFileSync(path); + +const wasmModule = new WebAssembly.Module(bytes); +const wasmInstance = new WebAssembly.Instance(wasmModule, imports); +wasm = wasmInstance.exports; +module.exports.__wasm = wasm; + diff --git a/anoncreds-rust/node/anoncreds_bg.wasm b/anoncreds-rust/node/anoncreds_bg.wasm new file mode 100644 index 000000000..92867cb7a Binary files /dev/null and b/anoncreds-rust/node/anoncreds_bg.wasm differ diff --git a/anoncreds-rust/node/anoncreds_bg.wasm.d.ts b/anoncreds-rust/node/anoncreds_bg.wasm.d.ts new file mode 100644 index 000000000..3f9ae1df8 --- /dev/null +++ b/anoncreds-rust/node/anoncreds_bg.wasm.d.ts @@ -0,0 +1,158 @@ +/* tslint:disable */ +/* eslint-disable */ +export const memory: WebAssembly.Memory; +export function anoncredsSetDefaultLogger(): number; +export function anoncredsCreateSchema(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; +export function anoncredsCreateCredentialDefinition(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number): void; +export function anoncredsCreateCredentialDefinitionCustom(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function anoncredsValidateCredentialDefinitionFromJson(a: number, b: number): void; +export function proverCreateLinkSecret(a: number): void; +export function proverCreateCredentialRequest(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function proverProcessCredential(a: number, b: number, c: number, d: number, e: number): number; +export function proverCreatePresentation(a: number, b: number, c: number, d: number, e: number, f: number): number; +export function generator_new(a: number): void; +export function generator_toBytes(a: number, b: number): void; +export function generator_fromBytes(a: number, b: number, c: number): void; +export function __wbg_signkey_free(a: number): void; +export function signkey_new(a: number): void; +export function signkey_fromSeed(a: number, b: number, c: number): void; +export function signkey_fromBytes(a: number, b: number, c: number): void; +export function signkey_toBytes(a: number, b: number): void; +export function verkey_new(a: number, b: number, c: number): void; +export function verkey_fromBytes(a: number, b: number, c: number): void; +export function verkey_toBytes(a: number, b: number): void; +export function proofofpossession_new(a: number, b: number, c: number): void; +export function __wbg_multisignature_free(a: number): void; +export function multisignature_new(a: number, b: number, c: number): void; +export function multisignature_fromBytes(a: number, b: number, c: number): void; +export function multisignature_toBytes(a: number, b: number): void; +export function __wbg_bls_free(a: number): void; +export function bls_new(): number; +export function bls_sign(a: number, b: number, c: number, d: number): void; +export function bls_verify(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function bls_verifyProofOfPosession(a: number, b: number, c: number, d: number): void; +export function bls_verifyMultiSignature(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function __wbg_credentialschema_free(a: number): void; +export function credentialschema_new(): number; +export function credentialschema_addAttr(a: number, b: number, c: number): void; +export function __wbg_credentialvalues_free(a: number): void; +export function credentialvalues_addMasterSecret(a: number, b: number, c: number): void; +export function credentialvalues_addKnown(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function credentialvalues_addHidden(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function credentialvalues_addCommitment(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function __wbg_credentialprimarypublickey_free(a: number): void; +export function __wbg_credentialpublickey_free(a: number): void; +export function credentialpublickey_getPrimaryKey(a: number, b: number): void; +export function credentialpublickey_getRevocationKey(a: number, b: number): void; +export function __wbg_credentialrevocationpublickey_free(a: number): void; +export function __wbg_credentialprivatekey_free(a: number): void; +export function __wbg_credentialkeycorrectnessproof_free(a: number): void; +export function __wbg_credentialdefinition_free(a: number): void; +export function __wbg_mastersecret_free(a: number): void; +export function mastersecret_new(a: number): void; +export function nonce_new(a: number): void; +export function __wbg_blindedcredentialsecrets_free(a: number): void; +export function __wbg_credentialsecretsblindingfactors_free(a: number): void; +export function __wbg_blindedcredentialsecretscorrectnessproof_free(a: number): void; +export function __wbg_proverblindedcredentialsecrets_free(a: number): void; +export function __wbg_credentialsignature_free(a: number): void; +export function credentialsignature_extractIndex(a: number, b: number): void; +export function __wbg_signaturecorrectnessproof_free(a: number): void; +export function __wbg_issuedcredential_free(a: number): void; +export function __wbg_issuedcredentialwithrevocation_free(a: number): void; +export function __wbg_revocationpublickey_free(a: number): void; +export function __wbg_revocationprivatekey_free(a: number): void; +export function __wbg_revocationregistry_free(a: number): void; +export function __wbg_revocationregistrydelta_free(a: number): void; +export function revocationregistrydelta_fromParts(a: number, b: number, c: number, d: number, e: number): void; +export function revocationregistrydelta_merge(a: number, b: number, c: number): void; +export function __wbg_revocationtailsgenerator_free(a: number): void; +export function revocationtailsgenerator_count(a: number): number; +export function revocationtailsgenerator_next(a: number, b: number): void; +export function __wbg_simpletailsaccessor_free(a: number): void; +export function simpletailsaccessor_new(a: number, b: number): void; +export function simpletailsaccessor_accessTail(a: number, b: number, c: number): void; +export function witness_new(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function witness_update(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function __wbg_proof_free(a: number): void; +export function __wbg_subproofrequest_free(a: number): void; +export function subproofrequest_new(): number; +export function subproofrequest_addPredicate(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function __wbg_proofbuilder_free(a: number): void; +export function proofbuilder_new(): number; +export function proofbuilder_addCommonAttribute(a: number, b: number, c: number): void; +export function proofbuilder_addSubProofRequest(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; +export function proofbuilder_finalize(a: number, b: number, c: number): void; +export function __wbg_proofverifier_free(a: number): void; +export function proofverifier_new(): number; +export function proofverifier_addSubProofRequest(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function proofverifier_verify(a: number, b: number, c: number, d: number): void; +export function issuer_newCredentialDefinition(a: number, b: number, c: number, d: number): void; +export function issuer_signCredential(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; +export function issuer_signCredentialWithRevocation(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number): void; +export function prover_blindedCredentialSecrets(a: number, b: number, c: number, d: number, e: number): void; +export function prover_processCredentialSignature(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number): void; +export function __wbg_ed25519sha512_free(a: number): void; +export function ed25519sha512_new(a: number): void; +export function ed25519sha512_fromSeed(a: number, b: number, c: number): void; +export function ed25519sha512_fromPrivateKey(a: number, b: number, c: number): void; +export function ed25519sha512_getPulicKey(a: number, b: number): void; +export function ed25519sha512_sign(a: number, b: number, c: number, d: number): void; +export function ed25519sha512_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function __wbg_wasmcipherkey_free(a: number): void; +export function ursaencryptor_new(a: number, b: number, c: number): void; +export function ursaencryptor_withKey(a: number, b: number, c: number, d: number, e: number): void; +export function ursaencryptor_encrypt(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function ursaencryptor_decrypt(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function ecdsasecp256k1sha256_keypair(a: number, b: number): void; +export function ecdsasecp256k1sha256_keypairFromSeed(a: number, b: number, c: number, d: number): void; +export function ecdsasecp256k1sha256_getPublicKey(a: number, b: number, c: number): void; +export function ecdsasecp256k1sha256_sign(a: number, b: number, c: number, d: number, e: number): void; +export function ecdsasecp256k1sha256_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; +export function ecdsasecp256k1sha256_normalizeS(a: number, b: number, c: number, d: number, e: number): void; +export function ecdsasecp256k1sha256_publicKeyCompressed(a: number, b: number): number; +export function ecdsasecp256k1sha256_publicKeyUnCompressed(a: number, b: number): number; +export function ecdsasecp256k1sha256_parseToPublicKey(a: number, b: number, c: number, d: number): void; +export function ecdhsecp256k1sha256_keypair(a: number, b: number): void; +export function ecdhsecp256k1sha256_keypair_from_seed(a: number, b: number, c: number, d: number): void; +export function ecdhsecp256k1sha256_getPublicKey(a: number, b: number, c: number): void; +export function ecdhsecp256k1sha256_computeSharedSecret(a: number, b: number, c: number, d: number): void; +export function x25519sha256_keypair(a: number, b: number): void; +export function x25519sha256_keypair_from_seed(a: number, b: number, c: number, d: number): void; +export function x25519sha256_getPublicKey(a: number, b: number, c: number): void; +export function x25519sha256_computeSharedSecret(a: number, b: number, c: number, d: number): void; +export function __wbg_wasmprivatekey_free(a: number): void; +export function wasmpublickey_new(a: number, b: number, c: number): void; +export function __wbg_nonce_free(a: number): void; +export function signature_toBytes(a: number, b: number): void; +export function proofofpossession_toBytes(a: number, b: number): void; +export function __wbg_keypair_free(a: number): void; +export function __wbg_noncredentialschema_free(a: number): void; +export function ecdsasecp256k1sha256_new(): number; +export function ecdhsecp256k1sha256_new(): number; +export function x25519sha256_new(): number; +export function __wbg_issuer_free(a: number): void; +export function __wbg_prover_free(a: number): void; +export function __wbg_ursaencryptor_free(a: number): void; +export function __wbg_ecdsasecp256k1sha256_free(a: number): void; +export function __wbg_ecdhsecp256k1sha256_free(a: number): void; +export function __wbg_x25519sha256_free(a: number): void; +export function noncredentialschema_new(): number; +export function credentialvalues_new(): number; +export function __wbg_tail_free(a: number): void; +export function __wbg_witness_free(a: number): void; +export function noncredentialschema_addAttr(a: number, b: number, c: number): void; +export function subproofrequest_addRevealedAttribute(a: number, b: number, c: number): void; +export function __wbg_verkey_free(a: number): void; +export function __wbg_signature_free(a: number): void; +export function __wbg_proofofpossession_free(a: number): void; +export function __wbg_generator_free(a: number): void; +export function __wbg_wasmpublickey_free(a: number): void; +export function __wbg_wasmsessionkey_free(a: number): void; +export function signature_fromBytes(a: number, b: number, c: number): void; +export function proofofpossession_fromBytes(a: number, b: number, c: number): void; +export function __wbindgen_malloc(a: number): number; +export function __wbindgen_realloc(a: number, b: number, c: number): number; +export function __wbindgen_add_to_stack_pointer(a: number): number; +export function __wbindgen_free(a: number, b: number): void; +export function __wbindgen_exn_store(a: number): void; diff --git a/anoncreds-rust/node/package.json b/anoncreds-rust/node/package.json new file mode 100644 index 000000000..ddcd611b4 --- /dev/null +++ b/anoncreds-rust/node/package.json @@ -0,0 +1,26 @@ +{ + "name": "anoncreds", + "collaborators": [ + "Hyperledger AnonCreds Contributors " + ], + "description": "Verifiable credential issuance and presentation for Hyperledger AnonCreds (https://www.hyperledger.org/projects), which provides a foundation for self-sovereign identity.", + "version": "0.1.0-dev.16", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/hyperledger/anoncreds-rs/" + }, + "files": [ + "anoncreds_bg.wasm", + "anoncreds.js", + "anoncreds.d.ts" + ], + "main": "anoncreds.js", + "types": "anoncreds.d.ts", + "keywords": [ + "hyperledger", + "ssi", + "verifiable", + "credentials" + ] +} \ No newline at end of file diff --git a/babel.config.js b/babel.config.js index 68a095321..6f51a5eca 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,19 +1,22 @@ +const test = process.env.NODE_ENV === "test"; + module.exports = { - presets: [ - "@babel/preset-typescript", - [ - "@babel/preset-env", - { - useBuiltIns: "usage", - corejs: 3, - }, - ], - "@babel/preset-react", - ], - plugins: [ - ["@babel/plugin-transform-typescript"], - "babel-plugin-transform-typescript-metadata", - ["@babel/plugin-proposal-decorators", {"legacy": true}], - ["@babel/plugin-proposal-class-properties", {"loose": false}], + presets: [ + "@babel/preset-typescript", + [ + "@babel/preset-env", + { + useBuiltIns: "usage", + corejs: 3, + }, ], + "@babel/preset-react", + ], + plugins: [ + "@babel/plugin-transform-typescript", + "babel-plugin-transform-typescript-metadata", + ["@babel/plugin-proposal-decorators", { "legacy": true }], + ["@babel/plugin-proposal-class-properties", { "loose": false }], + ...(test ? ['babel-plugin-transform-import-meta'] : []), + ], }; diff --git a/demos/browser/.gitignore b/demos/browser/.gitignore index 4d29575de..7222d9636 100644 --- a/demos/browser/.gitignore +++ b/demos/browser/.gitignore @@ -21,3 +21,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +public/*.wasm \ No newline at end of file diff --git a/demos/browser/craco.config.js b/demos/browser/craco.config.js index f933cceb7..9d10ef15a 100644 --- a/demos/browser/craco.config.js +++ b/demos/browser/craco.config.js @@ -1,34 +1,37 @@ - +const CopyPlugin = require("copy-webpack-plugin"); +const path = require("path"); module.exports = { webpack: { configure: (webpackConfig) => { + webpackConfig.resolve.extensions.push(".wasm"); // To resolve .wasm extensions - // const wasmLoader = { - // test: /\.wasm$/, - // type: "webassembly/async", - // }; - - // webpackConfig.module.rules = [ - // ...webpackConfig.module.rules, - // wasmLoader - // ] - - // webpackConfig.experiments = { - // asyncWebAssembly: true, - // syncWebAssembly: true, - // } - + webpackConfig.plugins = [ + new CopyPlugin({ + patterns: [ + { + context: + "node_modules/@input-output-hk/atala-prism-wallet-sdk/build/browser/", + from: path.resolve( + __dirname, + "node_modules/@input-output-hk/atala-prism-wallet-sdk/build/browser/*.wasm" + ), + to: path.resolve(__dirname, "public"), + }, + ], + }), + ...(webpackConfig.plugins || []), + ]; webpackConfig.resolve.fallback = { fs: false, - crypto: false, + crypto: false, // assert: require.resolve("assert/"), // url: require.resolve("url/"), // buffer: require.resolve("buffer/"), stream: require.resolve("stream-browserify"), path: require.resolve("path-browserify"), //util: require.resolve("util/"), - } + }; return webpackConfig; }, diff --git a/demos/browser/package-lock.json b/demos/browser/package-lock.json index 0773c4c14..feccf9f09 100644 --- a/demos/browser/package-lock.json +++ b/demos/browser/package-lock.json @@ -22,12 +22,15 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "typescript": "^4.9.5", + "wasm-loader": "^1.3.0", "web-vitals": "^2.1.4" }, "devDependencies": { - "@craco/craco": "^7.1.0", + "@babel/plugin-proposal-private-property-in-object": "^7.21.11", + "@craco/craco": "^5.9.0", "assert": "^2.0.0", "buffer": "^6.0.3", + "copy-webpack-plugin": "^11.0.0", "path-browserify": "^1.0.1", "stream-browserify": "^3.0.0", "url": "^0.11.0" @@ -44,6 +47,7 @@ "@stablelib/uuid": "^1.0.2", "@stablelib/wipe": "^1.0.1", "@stablelib/x25519": "^1.0.3", + "anoncreds": "../anoncreds-rs/pkg", "antlr4ts": "^0.5.0-alpha.4", "assert": "^2.0.0", "axios": "^1.3.4", @@ -74,6 +78,7 @@ "@rollup/plugin-commonjs": "^25.0.0", "@rollup/plugin-inject": "^5.0.3", "@rollup/plugin-json": "^6.0.0", + "@rollup/plugin-node-resolve": "^15.2.1", "@rollup/plugin-terser": "^0.4.3", "@rollup/plugin-wasm": "^6.1.3", "@semantic-release/changelog": "^6.0.3", @@ -85,6 +90,7 @@ "@types/chai-as-promised": "^7.1.5", "@types/elliptic": "^6.4.14", "@types/google-protobuf": "^3.15.6", + "@types/jest": "^29.5.5", "@types/node": "^18.14.2", "@types/sinon": "^10.0.13", "@types/sinon-chai": "^3.2.9", @@ -92,6 +98,7 @@ "@types/uuid": "^9.0.1", "@typescript-eslint/eslint-plugin": "^5.56.0", "@typescript-eslint/parser": "^5.55.0", + "babel-plugin-transform-import-meta": "^2.2.0", "babel-plugin-transform-typescript-metadata": "^0.3.2", "chai": "^4.3.7", "chai-as-promised": "^7.1.1", @@ -112,6 +119,7 @@ "replace": "^1.2.2", "rollup-plugin-cleanup": "^3.2.1", "rollup-plugin-ignore": "^1.0.10", + "rollup-plugin-jscc": "^2.0.0", "rollup-plugin-modify": "^3.0.0", "rollup-plugin-polyfill-node": "^0.12.0", "rollup-plugin-typescript2": "^0.34.1", @@ -8376,9 +8384,10 @@ } }, "../../node_modules/get-func-name": { - "version": "2.0.0", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", "dev": true, - "license": "MIT", "engines": { "node": "*" } @@ -20307,6 +20316,136 @@ "url": "https://github.com/sponsors/wooorm" } }, + "../atala-prism-wallet-sdk-ts": { + "name": "@input-output-hk/atala-prism-wallet-sdk", + "version": "2.0.0", + "extraneous": true, + "dependencies": { + "@scure/bip39": "^1.1.1", + "@stablelib/base64": "^1.0.1", + "@stablelib/sha256": "^1.0.1", + "@stablelib/uuid": "^1.0.2", + "@stablelib/wipe": "^1.0.1", + "@stablelib/x25519": "^1.0.3", + "antlr4ts": "^0.5.0-alpha.4", + "axios": "^1.3.4", + "bn.js": "^5.2.1", + "core-js": "^3.29.1", + "did-jwt": "^6.11.5", + "did-resolver": "^4.1.0", + "didcomm": "^0.4.0", + "elliptic": "^6.5.4", + "google-protobuf": "^3.21.2", + "hash.js": "1.1.7", + "jose": "^4.12.2", + "jsonwebtoken": "^9.0.0", + "localforage": "^1.10.0", + "multiformats": "^9.9.0", + "typeorm": "^0.3.12" + }, + "devDependencies": { + "@babel/cli": "^7.21.0", + "@babel/core": "^7.20.12", + "@babel/plugin-proposal-class-properties": "^7.16.0", + "@babel/plugin-proposal-decorators": "^7.21.0", + "@babel/plugin-transform-typescript": "^7.21.0", + "@babel/polyfill": "^7.12.1", + "@babel/preset-env": "^7.20.2", + "@babel/preset-react": "^7.18.6", + "@babel/preset-typescript": "^7.21.0", + "@rollup/plugin-commonjs": "^25.0.0", + "@rollup/plugin-inject": "^5.0.3", + "@rollup/plugin-json": "^6.0.0", + "@rollup/plugin-node-resolve": "^15.0.2", + "@rollup/plugin-replace": "^5.0.2", + "@rollup/plugin-terser": "^0.4.3", + "@rollup/plugin-typescript": "^11.1.1", + "@rollup/plugin-wasm": "^6.1.3", + "@scure/bip32": "^1.3.0", + "@semantic-release/changelog": "^6.0.3", + "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/exec": "^6.0.3", + "@semantic-release/git": "^10.0.1", + "@semantic-release/release-notes-generator": "^10.0.3", + "@types/antlr4": "^4.11.2", + "@types/chai": "^4.3.4", + "@types/chai-as-promised": "^7.1.5", + "@types/elliptic": "^6.4.14", + "@types/estree": "^1.0.0", + "@types/google-protobuf": "^3.15.6", + "@types/jest": "^29.4.0", + "@types/node": "^18.14.2", + "@types/react": "^18.0.28", + "@types/react-dom": "^18.0.11", + "@types/sinon": "^10.0.13", + "@types/sinon-chai": "^3.2.9", + "@types/sql.js": "^1.4.4", + "@types/uuid": "^9.0.1", + "@typescript-eslint/eslint-plugin": "^5.56.0", + "@typescript-eslint/parser": "^5.55.0", + "assert": "^2.0.0", + "babel-eslint": "^10.1.0", + "babel-loader": "^9.1.2", + "babel-plugin-transform-typescript-metadata": "^0.3.2", + "babel-preset-minify": "^0.5.2", + "babel-preset-react": "^6.24.1", + "buffer": "^6.0.3", + "chai": "^4.3.7", + "chai-as-promised": "^7.1.1", + "clean-webpack-plugin": "^4.0.0", + "concurrently": "^7.6.0", + "copy-webpack-plugin": "^11.0.0", + "css-loader": "^6.7.3", + "css-minimizer-webpack-plugin": "^4.2.2", + "didcomm-node": "^0.4.0", + "eslint": "^8.36.0", + "eslint-config-standard-with-typescript": "^34.0.1", + "eslint-plugin-import": "^2.27.5", + "eslint-plugin-n": "^15.6.1", + "eslint-plugin-promise": "^6.1.1", + "eslint-plugin-react": "^7.32.2", + "file-loader": "^6.2.0", + "html-webpack-plugin": "^5.5.0", + "inversify": "^6.0.1", + "jest": "^29.5.0", + "jotai": "^2.0.3", + "json-loader": "^0.5.7", + "mini-css-extract-plugin": "^2.7.3", + "process": "^0.11.10", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "replace": "^1.2.2", + "rollup-plugin-cleanup": "^3.2.1", + "rollup-plugin-ignore": "^1.0.10", + "rollup-plugin-node-externals": "^6.0.1", + "rollup-plugin-node-polyfills": "^0.2.1", + "rollup-plugin-polyfill-node": "^0.12.0", + "rollup-plugin-typescript2": "^0.34.1", + "semantic-release": "^19.0.5", + "semantic-release-slack-bot": "^3.5.3", + "sinon": "^15.0.1", + "sinon-chai": "^3.7.0", + "sql.js": "^1.8.0", + "sqlite3": "^5.1.6", + "style-loader": "^3.3.1", + "terser-webpack-plugin": "^5.3.7", + "typedoc": "^0.24.8", + "typedoc-plugin-markdown": "3.15.3", + "typedoc-plugin-rename-defaults": "^0.6.5", + "typedoc-plugin-superstruct": "^1.0.0", + "typedoc-theme-hierarchy": "^4.0.0", + "typeorm": "^0.3.17", + "typescript": "^4.9.5", + "uuid": "^9.0.0", + "webpack": "^5.76.0", + "webpack-node-externals": "^3.0.0" + }, + "peerDependenciesMeta": { + "react-native-sqlite-storage": { + "optional": true + } + } + }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "license": "MIT", @@ -20983,8 +21122,17 @@ } }, "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.0-placeholder-for-preset-env.2", - "license": "MIT", + "version": "7.21.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + }, "engines": { "node": ">=6.9.0" }, @@ -22157,6 +22305,17 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/preset-env/node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.0-placeholder-for-preset-env.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", + "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/preset-env/node_modules/semver": { "version": "6.3.1", "license": "ISC", @@ -22282,32 +22441,31 @@ "peer": true }, "node_modules/@craco/craco": { - "version": "7.1.0", + "version": "5.9.0", + "resolved": "https://registry.npmjs.org/@craco/craco/-/craco-5.9.0.tgz", + "integrity": "sha512-2Q8gIB4W0/nPiUxr9iAKUhGsFlXYN0/wngUdK1VWtfV2NtBv+yllNn2AjieaLbttgpQinuOYmDU65vocC0NMDg==", "dev": true, - "license": "Apache-2.0", "dependencies": { - "autoprefixer": "^10.4.12", - "cosmiconfig": "^7.0.1", - "cosmiconfig-typescript-loader": "^1.0.0", - "cross-spawn": "^7.0.3", - "lodash": "^4.17.21", - "semver": "^7.3.7", - "webpack-merge": "^5.8.0" + "cross-spawn": "^7.0.0", + "lodash": "^4.17.15", + "webpack-merge": "^4.2.2" }, "bin": { - "craco": "dist/bin/craco.js" + "craco": "bin/craco.js" }, "engines": { "node": ">=6" }, "peerDependencies": { - "react-scripts": "^5.0.0" + "react-scripts": "*" } }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -22319,6 +22477,8 @@ "version": "0.3.9", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -23705,22 +23865,30 @@ "node_modules/@tsconfig/node10": { "version": "1.0.9", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/@types/aria-query": { "version": "5.0.1", @@ -24475,6 +24643,7 @@ "node_modules/acorn": { "version": "8.10.0", "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -24583,7 +24752,6 @@ "version": "2.1.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ajv": "^8.0.0" }, @@ -24600,7 +24768,6 @@ "version": "8.12.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -24615,8 +24782,7 @@ "node_modules/ajv-formats/node_modules/json-schema-traverse": { "version": "1.0.0", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/ajv-keywords": { "version": "3.5.2", @@ -24928,6 +25094,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "browserslist": "^4.21.10", "caniuse-lite": "^1.0.30001520", @@ -25187,6 +25354,17 @@ "babel-plugin-transform-react-remove-prop-types": "^0.4.24" } }, + "node_modules/babylon": { + "version": "7.0.0-beta.47", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.47.tgz", + "integrity": "sha512-+rq2cr4GDhtToEzKFD6KZZMDBXhjFAr9JjPw9pAppZACeEWqNM294j+NdBzkSHYXwzzBmVjZ3nEVJlOhbR2gOQ==", + "bin": { + "babylon": "bin/babylon.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "license": "MIT" @@ -25233,9 +25411,7 @@ }, "node_modules/big.js": { "version": "5.2.2", - "dev": true, "license": "MIT", - "peer": true, "engines": { "node": "*" } @@ -25679,19 +25855,6 @@ "wrap-ansi": "^7.0.0" } }, - "node_modules/clone-deep": { - "version": "4.0.1", - "dev": true, - "license": "MIT", - "dependencies": { - "is-plain-object": "^2.0.4", - "kind-of": "^6.0.2", - "shallow-clone": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/co": { "version": "4.6.0", "dev": true, @@ -25969,6 +26132,114 @@ "license": "MIT", "peer": true }, + "node_modules/copy-webpack-plugin": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-11.0.0.tgz", + "integrity": "sha512-fX2MWpamkW0hZxMEg0+mYnA40LTosOSa5TqZ9GYIBzyJa9C3QUaMPSE2xAi/buNr8u89SfD9wHSQVBzrRa/SOQ==", + "dev": true, + "dependencies": { + "fast-glob": "^3.2.11", + "glob-parent": "^6.0.1", + "globby": "^13.1.1", + "normalize-path": "^3.0.0", + "schema-utils": "^4.0.0", + "serialize-javascript": "^6.0.0" + }, + "engines": { + "node": ">= 14.15.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.1.0" + } + }, + "node_modules/copy-webpack-plugin/node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/copy-webpack-plugin/node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "ajv": "^8.8.2" + } + }, + "node_modules/copy-webpack-plugin/node_modules/globby": { + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.2.2.tgz", + "integrity": "sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==", + "dev": true, + "dependencies": { + "dir-glob": "^3.0.1", + "fast-glob": "^3.3.0", + "ignore": "^5.2.4", + "merge2": "^1.4.1", + "slash": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/copy-webpack-plugin/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/copy-webpack-plugin/node_modules/schema-utils": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz", + "integrity": "sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.9.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.1.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/copy-webpack-plugin/node_modules/slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/core-js": { "version": "3.32.1", "dev": true, @@ -26022,28 +26293,12 @@ "node": ">=10" } }, - "node_modules/cosmiconfig-typescript-loader": { - "version": "1.0.9", - "dev": true, - "license": "MIT", - "dependencies": { - "cosmiconfig": "^7", - "ts-node": "^10.7.0" - }, - "engines": { - "node": ">=12", - "npm": ">=6" - }, - "peerDependencies": { - "@types/node": "*", - "cosmiconfig": ">=7", - "typescript": ">=3" - } - }, "node_modules/create-require": { "version": "1.1.1", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/cross-spawn": { "version": "7.0.3", @@ -26700,6 +26955,8 @@ "version": "4.0.2", "dev": true, "license": "BSD-3-Clause", + "optional": true, + "peer": true, "engines": { "node": ">=0.3.1" } @@ -26919,9 +27176,7 @@ }, "node_modules/emojis-list": { "version": "3.0.0", - "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">= 4" } @@ -27846,8 +28101,7 @@ }, "node_modules/fast-deep-equal": { "version": "3.1.3", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/fast-glob": { "version": "3.3.1", @@ -28225,6 +28479,7 @@ "version": "4.3.1", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": "*" }, @@ -28399,7 +28654,6 @@ "node_modules/glob-parent": { "version": "6.0.2", "license": "ISC", - "peer": true, "dependencies": { "is-glob": "^4.0.3" }, @@ -29313,17 +29567,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-plain-object": { - "version": "2.0.4", - "dev": true, - "license": "MIT", - "dependencies": { - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "dev": true, @@ -29484,14 +29727,6 @@ "version": "2.0.0", "license": "ISC" }, - "node_modules/isobject": { - "version": "3.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/istanbul-lib-coverage": { "version": "3.2.0", "dev": true, @@ -30698,6 +30933,7 @@ "version": "6.0.3", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -30843,6 +31079,14 @@ "license": "MIT", "peer": true }, + "node_modules/long": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", + "integrity": "sha512-ZYvPPOMqUwPoDsbJaR10iQJYnMuZhRTvHYl62ErLIEX7RgFlziSBUUvrt3OVfc47QlHHpzPZYP17g3Fv7oeJkg==", + "engines": { + "node": ">=0.6" + } + }, "node_modules/loose-envify": { "version": "1.4.0", "license": "MIT", @@ -30912,7 +31156,9 @@ "node_modules/make-error": { "version": "1.3.6", "dev": true, - "license": "ISC" + "license": "ISC", + "optional": true, + "peer": true }, "node_modules/makeerror": { "version": "1.0.12", @@ -31248,7 +31494,6 @@ "version": "3.0.0", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -31257,6 +31502,7 @@ "version": "0.1.2", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -33112,7 +33358,8 @@ "node_modules/postcss-value-parser": { "version": "4.2.0", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/prelude-ls": { "version": "1.2.1", @@ -33238,7 +33485,6 @@ "node_modules/punycode": { "version": "2.3.0", "license": "MIT", - "peer": true, "engines": { "node": ">=6" } @@ -33304,7 +33550,6 @@ "version": "2.1.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "safe-buffer": "^5.1.0" } @@ -33721,7 +33966,6 @@ "version": "2.0.2", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -34183,7 +34427,6 @@ "version": "6.0.1", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "randombytes": "^2.1.0" } @@ -34287,17 +34530,6 @@ "license": "ISC", "peer": true }, - "node_modules/shallow-clone": { - "version": "3.0.1", - "dev": true, - "license": "MIT", - "dependencies": { - "kind-of": "^6.0.2" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/shebang-command": { "version": "2.0.0", "license": "MIT", @@ -35309,6 +35541,8 @@ "version": "10.9.1", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -35351,6 +35585,8 @@ "version": "8.2.0", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">=0.4.0" } @@ -35358,7 +35594,9 @@ "node_modules/ts-node/node_modules/arg": { "version": "4.1.3", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/tsconfig-paths": { "version": "3.14.2", @@ -35653,7 +35891,6 @@ "node_modules/uri-js": { "version": "4.4.1", "license": "BSD-2-Clause", - "peer": true, "dependencies": { "punycode": "^2.1.0" } @@ -35741,7 +35978,9 @@ "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/v8-to-istanbul": { "version": "8.1.1", @@ -35796,6 +36035,54 @@ "makeerror": "1.0.12" } }, + "node_modules/wasm-dce": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wasm-dce/-/wasm-dce-1.0.2.tgz", + "integrity": "sha512-Fq1+nu43ybsjSnBquLrW/cULmKs61qbv9k8ep13QUe0nABBezMoNAA+j6QY66MW0/eoDVDp1rjXDqQ2VKyS/Xg==", + "dependencies": { + "@babel/core": "^7.0.0-beta.39", + "@babel/traverse": "^7.0.0-beta.39", + "@babel/types": "^7.0.0-beta.39", + "babylon": "^7.0.0-beta.39", + "webassembly-interpreter": "0.0.30" + } + }, + "node_modules/wasm-loader": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/wasm-loader/-/wasm-loader-1.3.0.tgz", + "integrity": "sha512-R4s75XH+o8qM+WaRrAU9S2rbAMDzob18/S3V8R9ZoFpZkPWLAohWWlzWAp1ybeTkOuuku/X1zJtxiV0pBYxZww==", + "dependencies": { + "loader-utils": "^1.1.0", + "wasm-dce": "^1.0.0" + }, + "peerDependencies": { + "wasm-dce": "1.x" + } + }, + "node_modules/wasm-loader/node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/wasm-loader/node_modules/loader-utils": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz", + "integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==", + "dependencies": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^1.0.1" + }, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/watchpack": { "version": "2.4.0", "dev": true, @@ -35822,6 +36109,32 @@ "version": "2.1.4", "license": "Apache-2.0" }, + "node_modules/webassembly-floating-point-hex-parser": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/webassembly-floating-point-hex-parser/-/webassembly-floating-point-hex-parser-0.1.2.tgz", + "integrity": "sha512-TUf1H++8U10+stJbFydnvrpG5Sznz5Rilez/oZlV5zI0C/e4cSxd8rALAJ8VpTvjVWxLmL3SVSJUK6Ap9AoiNg==", + "engines": { + "node": "*" + } + }, + "node_modules/webassembly-interpreter": { + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/webassembly-interpreter/-/webassembly-interpreter-0.0.30.tgz", + "integrity": "sha512-+Jdy2piEvz9T5j751mOE8+rBO12p+nNW6Fg4kJZ+zP1oUfsm+151sbAbM8AFxWTURmWCGP+r8Lxwfv3pzN1bCQ==", + "dependencies": { + "@babel/code-frame": "^7.0.0-beta.36", + "long": "^3.2.0", + "webassembly-floating-point-hex-parser": "0.1.2" + }, + "bin": { + "wasm": "lib/bin/repl.js", + "wasm2wast": "lib/bin/wasm2wast.js", + "wasmast": "lib/bin/wasmast.js", + "wasmdump": "lib/bin/wasmdump.js", + "wasmrun": "lib/bin/wasmrun.js", + "wastast": "lib/bin/wastast.js" + } + }, "node_modules/webidl-conversions": { "version": "6.1.0", "dev": true, @@ -36126,15 +36439,12 @@ } }, "node_modules/webpack-merge": { - "version": "5.9.0", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz", + "integrity": "sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g==", "dev": true, - "license": "MIT", "dependencies": { - "clone-deep": "^4.0.1", - "wildcard": "^2.0.0" - }, - "engines": { - "node": ">=10.0.0" + "lodash": "^4.17.15" } }, "node_modules/webpack-sources": { @@ -36319,11 +36629,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/wildcard": { - "version": "2.0.1", - "dev": true, - "license": "MIT" - }, "node_modules/workbox-background-sync": { "version": "6.6.0", "dev": true, @@ -36763,6 +37068,8 @@ "version": "3.1.1", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">=6" } diff --git a/demos/browser/package.json b/demos/browser/package.json index 996a96d0a..5e726e5fe 100644 --- a/demos/browser/package.json +++ b/demos/browser/package.json @@ -17,10 +17,11 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "typescript": "^4.9.5", + "wasm-loader": "^1.3.0", "web-vitals": "^2.1.4" }, "scripts": { - "start": "craco start", + "start": "npm run build && craco start", "build": "craco build", "test": "craco test" }, @@ -43,9 +44,11 @@ ] }, "devDependencies": { - "@craco/craco": "^7.1.0", + "@babel/plugin-proposal-private-property-in-object": "^7.21.11", + "@craco/craco": "^5.9.0", "assert": "^2.0.0", "buffer": "^6.0.3", + "copy-webpack-plugin": "^11.0.0", "path-browserify": "^1.0.1", "stream-browserify": "^3.0.0", "url": "^0.11.0" diff --git a/demos/browser/public/didcomm_js_bg.wasm b/demos/browser/public/didcomm_js_bg.wasm deleted file mode 100644 index 7b8e8b3d6..000000000 Binary files a/demos/browser/public/didcomm_js_bg.wasm and /dev/null differ diff --git a/demos/browser/src/App.tsx b/demos/browser/src/App.tsx index 278893a6e..288d52342 100644 --- a/demos/browser/src/App.tsx +++ b/demos/browser/src/App.tsx @@ -1,10 +1,10 @@ /* eslint-disable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/rules-of-hooks */ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import React, {useCallback, useEffect, useMemo, useState} from "react"; +import React, { useCallback, useEffect, useMemo, useState } from "react"; import "./App.css"; import * as jose from "jose"; -import {useAtom} from "jotai"; +import { useAtom } from "jotai"; import * as SDK from "@input-output-hk/atala-prism-wallet-sdk"; import { mnemonicsAtom } from "./state"; import { trimString } from "./utils"; @@ -21,16 +21,16 @@ const RequestPresentation = SDK.RequestPresentation; const apollo = new SDK.Apollo(); const castor = new SDK.Castor(apollo); const api = new SDK.ApiImpl(); -const defaultMediatorDID = "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9zaXQtcHJpc20tbWVkaWF0b3IuYXRhbGFwcmlzbS5pbyIsInIiOltdLCJhIjpbImRpZGNvbW0vdjIiXX0" +const defaultMediatorDID = "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9zaXQtcHJpc20tbWVkaWF0b3IuYXRhbGFwcmlzbS5pbyIsInIiOltdLCJhIjpbImRpZGNvbW0vdjIiXX0"; const pluto = new PlutoInMemory(); const useSDK = (mediatorDID: SDK.Domain.DID) => { - const didcomm = useMemo(() => new SDK.DIDCommWrapper(apollo, castor, pluto), []); - const mercury = useMemo(() => new SDK.Mercury(castor, didcomm, api), []); - const store = useMemo(() => new SDK.PublicMediatorStore(pluto), []); - const handler = useMemo(() => new SDK.BasicMediatorHandler(mediatorDID, mercury, store), []); - const manager = useMemo(() => new SDK.ConnectionsManager(castor, mercury, pluto, handler), []); - const agent = useMemo(() => new SDK.Agent( + const didcomm = new SDK.DIDCommWrapper(apollo, castor, pluto); + const mercury = new SDK.Mercury(castor, didcomm, api); + const store = new SDK.PublicMediatorStore(pluto); + const handler = new SDK.BasicMediatorHandler(mediatorDID, mercury, store); + const manager = new SDK.ConnectionsManager(castor, mercury, pluto, handler); + const agent = new SDK.Agent( apollo, castor, pluto, @@ -38,51 +38,51 @@ const useSDK = (mediatorDID: SDK.Domain.DID) => { handler, manager, apollo.createRandomSeed().seed - ), []); - return {agent, pluto}; + ); + return { agent, pluto }; }; function Mnemonics() { const mnemonicState = useAtom(mnemonicsAtom); - const [mnemonics, setMnemonics] = mnemonicState + const [mnemonics, setMnemonics] = mnemonicState; function createMnemonics() { (setMnemonics as any)(apollo.createRandomMnemonics()); } return ( - -

Mnemonics and keys

+ +

Mnemonics and keys

- - -
- {mnemonics - ? mnemonics.map((word, i) => ( - + + +
+ {mnemonics + ? mnemonics.map((word, i) => ( + {i + 1}. {word} - )) - : null} -
- + )) + : null} +
+
); } -function KeyPair({curve = SDK.Domain.Curve.SECP256K1}: { curve?: SDK.Domain.Curve }) { +function KeyPair({ curve = SDK.Domain.Curve.SECP256K1 }: { curve?: SDK.Domain.Curve; }) { const [mnemonics] = useAtom(mnemonicsAtom); // let [keyPair, setKeyPair] = React.useState(null); const [keyPair, setKeyPair] = React.useState(); @@ -95,7 +95,7 @@ function KeyPair({curve = SDK.Domain.Curve.SECP256K1}: { curve?: SDK.Domain.Curv const type = curve === SDK.Domain.Curve.X25519 ? SDK.Domain.KeyTypes.Curve25519 : SDK.Domain.KeyTypes.EC; const privateKey = apollo.createPrivateKey({ type: type, - curve:curve, + curve: curve, seed: Buffer.from(seed.value).toString("hex"), }); @@ -107,56 +107,56 @@ function KeyPair({curve = SDK.Domain.Curve.SECP256K1}: { curve?: SDK.Domain.Curv } return ( +
+

{curve} key pair

+ +
-

{curve} key pair

- - -
- {keyPair ? ( -
-

- Curve: {keyPair.curve} -

-

- Public key:{" "} - {trimString(jose.base64url.encode(keyPair.publicKey.value), 50)} -

-

- Private key:{" "} - {trimString(jose.base64url.encode(keyPair.privateKey.value), 50)} -

- -
- - -
- ) : ( -

No key pair created

- )} -
+ {keyPair ? ( +
+

+ Curve: {keyPair.curve} +

+

+ Public key:{" "} + {trimString(jose.base64url.encode(keyPair.publicKey.value), 50)} +

+

+ Private key:{" "} + {trimString(jose.base64url.encode(keyPair.privateKey.value), 50)} +

+ +
+ + +
+ ) : ( +

No key pair created

+ )}
+
); } -function Signatures({keyPair}: { keyPair: SDK.Domain.KeyPair }) { +function Signatures({ keyPair }: { keyPair: SDK.Domain.KeyPair; }) { const [signatureEncoded, setSignatureEncoded] = React.useState(undefined); const [isSignatureValid, setIsSignatureValid] = React.useState(undefined); function signData() { - if (keyPair.privateKey.isSignable() ) { - const helloWorldSig = keyPair.privateKey.sign(Buffer.from( "hello world")) + if (keyPair.privateKey.isSignable()) { + const helloWorldSig = keyPair.privateKey.sign(Buffer.from("hello world")); setSignatureEncoded(jose.base64url.encode(helloWorldSig)); } } @@ -168,7 +168,7 @@ function Signatures({keyPair}: { keyPair: SDK.Domain.KeyPair }) { try { if (keyPair.publicKey.canVerify()) { - isValid = keyPair.publicKey.verify(Buffer.from("hello world"), Buffer.from(jose.base64url.decode(signatureEncoded))) + isValid = keyPair.publicKey.verify(Buffer.from("hello world"), Buffer.from(jose.base64url.decode(signatureEncoded))); } } catch (e) { @@ -184,21 +184,21 @@ function Signatures({keyPair}: { keyPair: SDK.Domain.KeyPair }) { } return ( -
- -

Signature of "hello world":

-