mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-06-26 21:01:41 +00:00
rsa key compat with go
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
const expect = require('chai').expect
|
||||
|
||||
const crypto = require('../src')
|
||||
const fixtures = require('./fixtures/go-key-rsa')
|
||||
|
||||
describe('libp2p-crypto', () => {
|
||||
let key
|
||||
@ -26,4 +27,48 @@ describe('libp2p-crypto', () => {
|
||||
|
||||
expect(key2.equals(key)).to.be.eql(true)
|
||||
})
|
||||
|
||||
describe('go interop', () => {
|
||||
it('unmarshals private key', () => {
|
||||
const key = crypto.unmarshalPrivateKey(fixtures.private.key)
|
||||
const hash = fixtures.private.hash
|
||||
|
||||
expect(
|
||||
key.hash()
|
||||
).to.be.eql(
|
||||
hash
|
||||
)
|
||||
})
|
||||
|
||||
it('unmarshals public key', () => {
|
||||
const key = crypto.unmarshalPublicKey(fixtures.public.key)
|
||||
const hash = fixtures.public.hash
|
||||
|
||||
expect(
|
||||
key.hash()
|
||||
).to.be.eql(
|
||||
hash
|
||||
)
|
||||
})
|
||||
|
||||
it('unmarshal -> marshal, private key', () => {
|
||||
const key = crypto.unmarshalPrivateKey(fixtures.private.key)
|
||||
const marshalled = crypto.marshalPrivateKey(key)
|
||||
expect(
|
||||
fixtures.private.key.equals(marshalled)
|
||||
).to.be.eql(
|
||||
true
|
||||
)
|
||||
})
|
||||
|
||||
it('unmarshal -> marshal, public key', () => {
|
||||
const key = crypto.unmarshalPublicKey(fixtures.public.key)
|
||||
const marshalled = crypto.marshalPublicKey(key)
|
||||
expect(
|
||||
fixtures.public.key.equals(marshalled)
|
||||
).to.be.eql(
|
||||
true
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user