mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[@types/sodium-native] Add crypto_box_* constants (#42079)
This commit is contained in:
parent
2fa35a8617
commit
11d1ff87d0
3
types/sodium-native/index.d.ts
vendored
3
types/sodium-native/index.d.ts
vendored
@ -114,6 +114,9 @@ export const crypto_secretstream_xchacha20poly1305_TAG_PUSH: number;
|
||||
export const crypto_secretstream_xchacha20poly1305_TAG_REKEY: number;
|
||||
/** NOTE: Unofficial constant */
|
||||
export const crypto_secretstream_xchacha20poly1305_TAGBYTES: number;
|
||||
export const crypto_box_SEALBYTES: number;
|
||||
export const crypto_box_PUBLICKEYBYTES: number;
|
||||
export const crypto_box_SECRETKEYBYTES: number;
|
||||
|
||||
/**
|
||||
* Zero out the data in `buffer`.
|
||||
|
||||
@ -98,3 +98,11 @@ sc.fill(0xcd, 0, sodium.crypto_core_ed25519_UNIFORMBYTES);
|
||||
sc2.fill(0x42, 0, sodium.crypto_core_ed25519_UNIFORMBYTES);
|
||||
sodium.crypto_core_ed25519_scalar_add(sc, sc2, sc);
|
||||
sodium.crypto_core_ed25519_scalar_sub(sc, sc, sc2);
|
||||
|
||||
const publicKey = sodium.sodium_malloc(sodium.crypto_box_PUBLICKEYBYTES);
|
||||
const secretKey = sodium.sodium_malloc(sodium.crypto_box_SECRETKEYBYTES);
|
||||
sodium.crypto_box_keypair(publicKey, secretKey);
|
||||
const message = sodium.sodium_malloc(4);
|
||||
const cipherText = sodium.sodium_malloc(message.length + sodium.crypto_box_SEALBYTES);
|
||||
sodium.crypto_box_seal(cipherText, message, publicKey);
|
||||
sodium.crypto_box_seal_open(message, cipherText, publicKey, secretKey);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user