What is the key scheme and encoding used in GUN?

97 Views Asked by At

What are the key schemes, sizes, and encodings used in GUN db?

I didn't find a quick answer on searching so am adding the question here.

The keys look like:

let lee = await SEA.pair()
>lee.pub

"wfcQUDB44NhKFikH4NhWKVZfhQY-xGRpwnZIHjgmwRI.xLxhMgWvgvYHCc95L6Ni2RLmjJCMowWNbR3eQ1r4MOU"

1

There are 1 best solutions below

1
On BEST ANSWER

For Signing/Verifying:

Gun uses ECDSA with the P-256 curve.

The keys are encoded in base64.

More specifically, the public key is a . delineated concatenation of the x and y output parameters from running exportKey on a JSON web key (JWK) CryptoKeyPair object obtained from the subtleCrypto.exportKey function (following key generation using subtleCrypto.generateKey with ECDSA P256 curve).

This has an overview of the x and y params.

For Encryption/Decryption:

Gun uses ECDH P-256 cruve with same process as above (public keys stored as lee.epub for OP example)