aboutsummaryrefslogtreecommitdiffstats
path: root/library/sodium-plus/lib/keytypes/ed25519sk.js
blob: 3c67286c2ba142a0ebd2ed5291061f40c017fe06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const CryptographyKey = require('../cryptography-key');

class Ed25519SecretKey extends CryptographyKey {
    constructor(buf) {
        if (buf.length !== 64) {
            throw new Error('Ed25519 secret keys must be 64 bytes long');
        }
        super(buf);
        this.keyType = 'ed25519';
        this.publicKey = false;
    }

    /**
     * @return {Ed25519SecretKey}
     */
    static from() {
        return new Ed25519SecretKey(Buffer.from(...arguments));
    }

    isEd25519Key() {
        return true;
    }

    isPublicKey() {
        return false;
    }
}

module.exports = Ed25519SecretKey;