diff --git a/bindings/channels.go b/bindings/channels.go index ead4eceb123b829fe8c45f4eb384ad0bc2441fd4..9b727c0db1c6d4e3f7fba0f8b824628339f14138 100644 --- a/bindings/channels.go +++ b/bindings/channels.go @@ -109,7 +109,7 @@ func (cm *ChannelsManager) GetID() int { // [Cmix.GetID]. // // Returns: -// - JSON of [channel.PrivateIdentity]. +// - Marshalled bytes of [channel.PrivateIdentity]. func GenerateChannelIdentity(cmixID int) ([]byte, error) { // Get user from singleton user, err := cmixTrackerSingleton.get(cmixID) @@ -126,6 +126,24 @@ func GenerateChannelIdentity(cmixID int) ([]byte, error) { return pi.Marshal(), nil } +// ConstructIdentity constructs a [channel.Identity] from a user's public key +// and codeset version. +// +// Parameters: +// - pubKey - The Ed25519 public key. +// - codesetVersion - The version of the codeset used to generate the identity. +// +// Returns: +// - JSON of [channel.Identity]. +func ConstructIdentity(pubKey []byte, codesetVersion int) ([]byte, error) { + identity, err := cryptoChannel.ConstructIdentity( + pubKey, uint8(codesetVersion)) + if err != nil { + return nil, err + } + return identity.Marshal(), nil +} + // ImportPrivateIdentity generates a new [channel.PrivateIdentity] from exported // data. // diff --git a/go.mod b/go.mod index 8a645be7f7d412bdcc4def2953582206d040ada5..b041546fa676d2524db9b2bff07a69748d0dc00f 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/stretchr/testify v1.8.0 gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f gitlab.com/elixxir/comms v0.0.4-0.20221017173926-4eaa6061dfaa - gitlab.com/elixxir/crypto v0.0.7-0.20221017173452-565da4101a3b + gitlab.com/elixxir/crypto v0.0.7-0.20221017204335-9201b3672f3a gitlab.com/elixxir/ekv v0.2.1 gitlab.com/elixxir/primitives v0.0.3-0.20221017172918-6176818d1aba gitlab.com/xx_network/comms v0.0.4-0.20221017172508-09e33697dc15 diff --git a/go.sum b/go.sum index 228e659a3bfdcb6c35fb46fb872f8bc87b73460c..1601ba4e3435a94b86e144a0c5b5f38c8d0cbfcc 100644 --- a/go.sum +++ b/go.sum @@ -635,8 +635,9 @@ gitlab.com/elixxir/comms v0.0.4-0.20221017173926-4eaa6061dfaa h1:/FEpu0N0rAyq74F gitlab.com/elixxir/comms v0.0.4-0.20221017173926-4eaa6061dfaa/go.mod h1:rW7xdbHntP2MoF3q+2+f+IR8OHol94MRyviotfR5rXg= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= gitlab.com/elixxir/crypto v0.0.3/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA= -gitlab.com/elixxir/crypto v0.0.7-0.20221017173452-565da4101a3b h1:5VBuenFNKOq0omDYmUet3Deu3pAkzNIkveQBtNO/o0k= gitlab.com/elixxir/crypto v0.0.7-0.20221017173452-565da4101a3b/go.mod h1:1rftbwSVdy49LkBIkPr+w+P2mDOerYeBKoZuB3r0yqI= +gitlab.com/elixxir/crypto v0.0.7-0.20221017204335-9201b3672f3a h1:RxobrpD5owwdyNg5KTqBINJ8z0zsXsbu+UhMEC80wIE= +gitlab.com/elixxir/crypto v0.0.7-0.20221017204335-9201b3672f3a/go.mod h1:1rftbwSVdy49LkBIkPr+w+P2mDOerYeBKoZuB3r0yqI= gitlab.com/elixxir/ekv v0.2.1 h1:dtwbt6KmAXG2Tik5d60iDz2fLhoFBgWwST03p7T+9Is= gitlab.com/elixxir/ekv v0.2.1/go.mod h1:USLD7xeDnuZEavygdrgzNEwZXeLQJK/w1a+htpN+JEU= gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg=