I found this example usage code in an npm repo that I've been examining https://github.com/cyph/pqcrypto.js/tree/master/packages/superdilithium.

import {superDilithium} from 'superdilithium';

const keyPair /*: {privateKey: Uint8Array; publicKey: Uint8Array} */ =
    await superDilithium.keyPair()
;

const message /*: Uint8Array */ =
    new Uint8Array([104, 101, 108, 108, 111]) // "hello"
;

// Optional additional data argument, similar conceptually to what AEAD cyphers support.
// If specified, must be the same when signing and verifying. For more information and
// usage advice, see: https://download.libsodium.org/doc/secret-key_cryptography/aead.html
const additionalData /*: Uint8Array */ =
    new Uint8Array([119, 111, 114, 108, 100]) // "world"
;

/* Combined signatures */

const signed /*: Uint8Array */ =
    await superDilithium.sign(message, keyPair.privateKey, additionalData)
;

const verified /*: Uint8Array */ =
    await superDilithium.open(signed, keyPair.publicKey, additionalData) // same as message
;  

It looks like new Uint8Array([104, 101, 108, 108, 111]) // "hello" is an array representation of the word "hello." How is this array derived? And is this a common practice in preparing letter-based strings for cryptographic signing? Why not just sign the raw string "hello?"

0

There are 0 best solutions below