diff --git a/types/sodium-native/index.d.ts b/types/sodium-native/index.d.ts index 92c9f86d0b..1b6779e105 100644 --- a/types/sodium-native/index.d.ts +++ b/types/sodium-native/index.d.ts @@ -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`. diff --git a/types/sodium-native/sodium-native-tests.ts b/types/sodium-native/sodium-native-tests.ts index 718394bd39..fa856592c7 100644 --- a/types/sodium-native/sodium-native-tests.ts +++ b/types/sodium-native/sodium-native-tests.ts @@ -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);