0.0.2 • Published 1 year ago

@reclaimprotocol/reclaim-crypto-sdk v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Reclaim crypto SDK

Crypto SDK Provides common functions for encrypting, decrypting, signing & verifying data used in Reclaim protocol. It's also used for generating & verifying auth tokens used in Reclaim backend

Setup

  1. Run npm i

Creating an account

  1. Generate a new wallet by calling const wallet = Wallet.createRandom()

Authentication

  1. Create an auth token by calling await generateAuthToken(wallet.privateKey)
  2. Validate token by calling authenticate(token)

Encrypting & decrypting data

Encryption

		const data = Buffer.from('{"a":"123","b":123}', 'utf8')
		const ciphertext = encryptData(
			utils.arrayify(bob.publicKey),
			utils.arrayify(alice.privateKey),
			data
		)

Decryption

		const plaintext = decryptData(
			utils.arrayify(bob.privateKey),
			utils.arrayify(alice.publicKey),
			ciphertext
		)

Signing & verification

        const data = Buffer.from('{"a":"123","b":123}', 'utf8')
        const signature = await signatures.sign(
            data,
            privateKey,
        )

Verification

        const addr = signatures.getAddress(utils.arrayify(publicKey))
        const res = await signatures.verify(data,signature,addr)
0.0.2

1 year ago

0.0.1

1 year ago