signing.js
function sign(secretKey, text) {
    const sec = parseSecretKey(secretKey);
    const bintext = Buffer.from(text, 'utf8');
    const sig = nacl.sign.detached(bintext, sec.key);
    // Full signature includes algorithm id ('Ed'), key number,
    // and the signature itself.
    const fullsig = new Uint8Array(2 + 8 + 64);
    fullsig[0] = 69 // 'E'
    fullsig[1] = 100; // 'd'
    fullsig.set(sec.num, 2) // key number
    fullsig.set(sig, 10); // signature
    return Buffer.from(fullsig.buffer).toString('base64');
}
function sign(secretKey, text) {
    const sec = parseSecretKey(secretKey);
    const bintext = Buffer.from(text, 'utf8');
    const sig = nacl.sign.detached(bintext, sec.key);
    // Full signature includes algorithm id ('Ed'), key number,
    // and the signature itself.
    const fullsig = new Uint8Array(2 + 8 + 64);
    fullsig[0] = 69 // 'E'
    fullsig[1] = 100; // 'd'
    fullsig.set(sec.num, 2) // key number
    fullsig.set(sig, 10); // signature
    return Buffer.from(fullsig.buffer).toString('base64');
}
function sign ( secretKey , text ) { const sec = parseSecretKey ( secretKey ) ; const bintext = Buffer . from ( text , 'utf8' ) ; const sig = nacl . sign . detached ( bintext , sec . key ) ; // Full signature includes algorithm id ('Ed'), key number, // and the signature itself. const fullsig = new Uint8Array ( 2 + 8 + 64 ) ; fullsig [ 0 ] = 69 // 'E' fullsig [ 1 ] = 100 ; // 'd' fullsig . set ( sec . num , 2 ) // key number fullsig . set ( sig , 10 ) ; // signature return Buffer . from ( fullsig . buffer ) . toString ( 'base64' ) ; }
Signs text with the given secret key, returning signature.

Note that secret key is stored in the same format as signify,
but requires rounds = 0, so it is unencrypted.

Secret key format:

2 bytes - signature algorithm
2 bytes - kdf algorithm ('B', 'K')
4 bytes - kdf rounds (00 00 00 00)
16 bytes - salt (any bytes, ignored)
8 bytes - checksum (SHA512(secret key))
8 bytes - key num (random bytes, embedded in signature and public key)
64 bytes - secret key

@param {string} secretKey
@param {string} text
@returns {string} signature
Signs text with the given secret key returning signature .