Shared Crypto Interface For The Quest Network
The Crypto class for the Quest Network Operating System offers shared crypto functionality.
npm install @questnetwork/quest-utilities-js@0.9.4
Returns a new secure AES passphrase.
let pwd = <os>.crypto.aes.generatePassphrase(length);
Hashes a secret for the specified amount of rounds, anything below 5000 rounds will default to 5000.
let hashed = <os>.crypto.aes.hashSecret(message,newSecret, rounds = 10);
Encrypts an object or utf8 string either with the whistle supplied or with a generated new whistle. Returns Base64.
let { secret, aesEncryptedB64 } = <os>.crypto.aes.encrypt('test');
Decrypts a B64 string with the whistle Returns String or Object.
let { secret, aesEncryptedB64 } = <os>.crypto.aes.decryptB64(aesEncryptedB64, secret, format = 'utf8')
Decrypts a Hex string with the whistle Returns String or Object.
let { secret, aesEncryptedB64 } = <os>.crypto.aes.decryptHex(aesEncryptedHex, secret, format = 'utf8')
Returns an ArrayBuffer of the input string.
let aB = <os>.crypto.convert.stringToArrayBuffer(string,'utf8');
Returns an ArrayBuffer of the input butter
let hashed = <os>.crypto.convert.bufferToArrayBuffer(buf);
Imports a key for WebCrypto.
await <os>.crypto.convert.importKey(alg,format,keyenc,key);
Digests data using the supplied algorithm.
let digest = await <os>.crypto.ec.digest('SHA-256',data);
Generates an EC keypair with maximum security according to the Quest Network protocol.
let keys = await <os>.crypto.ec.generateKeyPair();
Signs an object with an EC private Hex key according to the Quest Network protocol.
let signedObject = await <os>.crypto.ec.sign(obj,keyHex);
Verifies a signed object with an EC public Hex key according to the Quest Network protocol.
if(await <os>.crypto.ec.verify(obj,keyHex)){
console.log('Signature Checks Out!');
}
Generates an RSA keypair with maximum security according to the Quest Network protocol.
let keys = await <os>.crypto.rsa.generateKeyPair();
Encrypts a string with an RSA private key
let encrypted = await <os>.crypto.rsa.fullEncrypt(plain,pubKey);
Decrypts a string with an RSA public key
let decrypted = await <os>.crypto.rsa.fullDecrypt(encrypted,pk);
Please consider supporting us, so that we can build a non-profit for this project (ツ)
Ethereum | Bitcoin |
---|---|
0xBC2A050E7B87610Bc29657e7e7901DdBA6f2D34E |
bc1qujrqa3s34r5h0exgmmcuf8ejhyydm8wwja4fmq |
GNU AGPLv3