diff --git a/bindings/channels.go b/bindings/channels.go index 9b727c0db1c6d4e3f7fba0f8b824628339f14138..a70a0bda2dd5862a97743abf5eff95db85e8e693 100644 --- a/bindings/channels.go +++ b/bindings/channels.go @@ -141,7 +141,7 @@ func ConstructIdentity(pubKey []byte, codesetVersion int) ([]byte, error) { if err != nil { return nil, err } - return identity.Marshal(), nil + return json.Marshal(identity) } // ImportPrivateIdentity generates a new [channel.PrivateIdentity] from exported diff --git a/bindings/follow.go b/bindings/follow.go index 56c653af47ac981c01b805d1a43079c1bbc60cb1..6f892e4151356b6bfa0906f2f746542aaae4c99e 100644 --- a/bindings/follow.go +++ b/bindings/follow.go @@ -99,6 +99,10 @@ func (c *Cmix) ReadyToSend() bool { jww.FATAL.Panicf("Failed to get node registration status: %+v", err) } + // FIXME: This is a fix put in place because not all nodes in the NDF are + // online. This should be fixed. + total = 340 + return numReg >= total*7/10 } diff --git a/cmix/nodes/request.go b/cmix/nodes/request.go index 499acb4550b2ff31ebf2e4a2d4a8f8c0ef1c707b..281b9a1190d42e06422473269761ecef94b3a8c0 100644 --- a/cmix/nodes/request.go +++ b/cmix/nodes/request.go @@ -8,6 +8,8 @@ package nodes import ( + "io" + "github.com/golang/protobuf/proto" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" @@ -27,7 +29,6 @@ import ( "gitlab.com/xx_network/crypto/tls" "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/netTime" - "io" ) // requestKey is a helper function which constructs a ClientKeyRequest message. @@ -184,7 +185,7 @@ func processRequestResponse(signedKeyResponse *pb.SignedKeyResponse, } // Verify the response signature - err = rsa.Verify(nodePubKey, opts.Hash, hashedResponse, + err = verifyNodeSignature(nodePubKey, opts.Hash, hashedResponse, signedKeyResponse.KeyResponseSignedByGateway.Signature, opts) if err != nil { return nil, nil, 0, diff --git a/cmix/nodes/verifyNodeSig.go b/cmix/nodes/verifyNodeSig.go new file mode 100644 index 0000000000000000000000000000000000000000..5fff372159890c1228e8c2e340dac68302a14f80 --- /dev/null +++ b/cmix/nodes/verifyNodeSig.go @@ -0,0 +1,22 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright © 2022 xx foundation // +// // +// Use of this source code is governed by a license that can be found in the // +// LICENSE file. // +//////////////////////////////////////////////////////////////////////////////// + +//go:build !js || !wasm + +package nodes + +import ( + "crypto" + + "gitlab.com/xx_network/crypto/signature/rsa" +) + +func verifyNodeSignature(pub *rsa.PublicKey, hash crypto.Hash, + hashed []byte, sig []byte, opts *rsa.Options) error { + // Verify the response signature + return rsa.Verify(pub, hash, hashed, sig, opts) +} diff --git a/cmix/nodes/verifyNodeSig_js.go b/cmix/nodes/verifyNodeSig_js.go new file mode 100644 index 0000000000000000000000000000000000000000..79b35ef789f4c263b88bdb2ee7853cb5a11ba80d --- /dev/null +++ b/cmix/nodes/verifyNodeSig_js.go @@ -0,0 +1,23 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright © 2022 xx foundation // +// // +// Use of this source code is governed by a license that can be found in the // +// LICENSE file. // +//////////////////////////////////////////////////////////////////////////////// + +//go:build js && wasm + +package nodes + +import ( + "crypto" + + jww "github.com/spf13/jwalterweatherman" + "gitlab.com/xx_network/crypto/signature/rsa" +) + +func verifyNodeSignature(pub *rsa.PublicKey, hash crypto.Hash, + hashed []byte, sig []byte, opts *rsa.Options) error { + jww.WARN.Printf("node signature checking disabled for wasm") + return nil +}