Verifies aggregated signatures, many messages signed by many
Returns a Promise<Uint8Array>
Crypto suites
static async createES256K(options: any)
Creates an ES256K universal wallet
Parameters
passphrase: Passphrase
walletid: A wallet id, set it to load a previously created wallet, otherwise leave empty
rpcUrl: An EVM Compatible chain (Ethereum, Binance Smart Chain, etc)
registry: Contract address for EVM compatible ethr-did registry
Returns a XDVUniversalProvider
did: A DID object from 3ID library. Allows to authenticate and sign with IPLD
secureMesssage: Uses EthCrypto for encrypting and decrypting
publicKey: A public key as an array like
issuer: A DID object for issue signers
web3: Web3 instance used by DApps
id: A wallet id
address: Wallet address
static async createEd25519(options: any)
Creates an Ed25519 universal wallet with DID Key as result.
Note: Signing only, support for X25519 will be added later
Parameters
passphrase: Passphrase
walletid: A wallet id, set it to load a previously created wallet, otherwise leave empty
Returns a XDVUniversalProvider
did: A DID object from 3ID library. Allows to authenticate and sign with IPLD
publicKey: A public key as an array like
getIssuer: A DID object for issue signers
privateKey: A private key as an array like
static async createWeb3Provider(options: any)
Creates a Web3 provider
Parameters
passphrase: Passphrase
walletid: A wallet id, set it to load a previously created wallet, otherwise leave empty
rpcUrl: An EVM Compatible chain (Ethereum, Binance Smart Chain, etc)
registry: Contract address for EVM compatible ethr-did registry
Returns a XDVUniversalProvider
secureMesssage: Uses EthCrypto for encrypting and decrypting
publicKey: A public key as an array like
web3: Web3 instance used by DApps
address: Wallet address
Use Cases and Implementations
How to create, import and open a wallet
/** * Creates a wallet account * @param accountName Account name * @param passphrase Passphrase */ async createAccount(accountName: string, passphrase: string) {// Set isWeb for browser usageconstxdvWallet=newWallet({ isWeb:true })// Unlocks walletawaitxdvWallet.open(accountName, passphrase) }/** * Creates a wallet * @param accountName Account name * @param passphrase Passphrase * @returns */ async createWallet(accountName: string, passphrase: string) {constxdvWallet=newWallet({ isWeb:true })awaitxdvWallet.open(accountName, passphrase)// Gets account, if null, user needs to enrollconstacct= (awaitxdvWallet.getAccount()) asanylet walletIdif (acct.keystores.length===0) {// Adds a wallet. walletId =awaitxdvWallet.addWallet() } else {// Gets first wallet walletId =acct.keystores[0].walletId }// Creates a wallet based on crypto suiteconstwallet=awaitxdvWallet.createEd25519({ passphrase: passphrase, walletId: walletId, })return wallet asany }/** * Imports an existing seed phrase * @param accountName Account name * @param passphrase Passphrase * @param mnemonic Seed phrase * @returns */ async importWallet( accountName: string, passphrase: string, mnemonic: string, ) {constxdvWallet=newWallet({ isWeb:true })awaitxdvWallet.open(accountName, passphrase)constacct= (awaitxdvWallet.getAccount()) asanyif (acct.keystores.length>0) {// already importedreturn xdvWallet }// Import wallet using existing mnemonicconstwalletId=awaitxdvWallet.addWallet({ mnemonic, })constwallet=awaitxdvWallet.createEd25519({ passphrase: passphrase, walletId: walletId, })return wallet asany }
How to encrypt between two parties
// Obtain a previously created accountlet acct =awaitwallet.getAccount()// add Alice and Bob wallets with auto generated mnemonicconstwalletAId=awaitwallet.addWallet()constwalletBId=awaitwallet.addWallet()// create DIDsconstdid=awaitwallet.createEd25519({ walletId: walletAId})constdidBob=awaitwallet.createEd25519({ walletId: walletBId})// create Alice IPLD ManagerconstipfsManager=newIPLDManager(did.did)awaitipfsManager.start()// Authenticate with DIDawaitdid.did.authenticate()awaitdidBob.did.authenticate()// Alice encrypts, and both Alice and Bob can decryptconstenc=awaitipfsManager.encryptObject('Hola Mundo !!!', [didBob.did.id,])// Bob DID decrypts contentconstres=awaitipfsManager.decryptObject(didBob.did,enc.toString(), {})expect(res.cleartext).toEqual('Hola Mundo !!!')