aboutsummaryrefslogtreecommitdiffstats
path: root/library/sodium-plus/lib/keytypes/x25519sk.js
blob: 8b8016f83368b979cf6556875d43dce26fe025b9 (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 X25519SecretKey extends CryptographyKey {
    constructor(buf) {
        if (buf.length !== 32) {
            throw new Error('X25519 secret keys must be 32 bytes long');
        }
        super(buf);
        this.keyType = 'x25519';
        this.publicKey = false;
    }

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

    isX25519Key() {
        return true;
    }

    isPublicKey() {
        return false;
    }
}

module.exports = X25519SecretKey;