@reclaimprotocol/crypto-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

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)

Readme

Keywords

Package Sidebar

Install

npm i @reclaimprotocol/crypto-sdk

Weekly Downloads

14

Version

1.4.0

License

ISC

Unpacked Size

88.6 kB

Total Files

74

Last publish

Collaborators

  • dwik-reclaim
  • scottbrown
  • kushal-shah
  • hadi_reclaim
  • alex.e
  • abdulrashid
  • ali0002