diff options
Diffstat (limited to 'library/sodium-plus/lib/keytypes/ed25519pk.js')
-rw-r--r-- | library/sodium-plus/lib/keytypes/ed25519pk.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/library/sodium-plus/lib/keytypes/ed25519pk.js b/library/sodium-plus/lib/keytypes/ed25519pk.js new file mode 100644 index 000000000..4c6dd911e --- /dev/null +++ b/library/sodium-plus/lib/keytypes/ed25519pk.js @@ -0,0 +1,28 @@ +const CryptographyKey = require('../cryptography-key'); + +class Ed25519PublicKey extends CryptographyKey { + constructor(buf) { + if (buf.length !== 32) { + throw new Error('Ed25519 public keys must be 32 bytes long'); + } + super(buf); + this.keyType = 'ed25519'; + this.publicKey = true; + } + /** + * @return {Ed25519PublicKey} + */ + static from() { + return new Ed25519PublicKey(Buffer.from(...arguments)); + } + + isEd25519Key() { + return true; + } + + isPublicKey() { + return true; + } +} + +module.exports = Ed25519PublicKey; |