1.4.0 • Published 9 months ago

@reclaimprotocol/crypto-sdk v1.4.0

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months 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)
1.4.0

9 months ago

1.3.0

9 months ago

1.2.1

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.2

1 year ago