aboutsummaryrefslogtreecommitdiffstats
path: root/library/sodium-plus/lib/keytypes/ed25519sk.js
diff options
context:
space:
mode:
Diffstat (limited to 'library/sodium-plus/lib/keytypes/ed25519sk.js')
-rw-r--r--library/sodium-plus/lib/keytypes/ed25519sk.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/library/sodium-plus/lib/keytypes/ed25519sk.js b/library/sodium-plus/lib/keytypes/ed25519sk.js
new file mode 100644
index 000000000..3c67286c2
--- /dev/null
+++ b/library/sodium-plus/lib/keytypes/ed25519sk.js
@@ -0,0 +1,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; \ No newline at end of file