From 0a0ce8f773752d2613bd7ad5916912012ce82fb5 Mon Sep 17 00:00:00 2001 From: Jono Wenger <jono@elixxir.io> Date: Fri, 14 Oct 2022 11:21:32 -0700 Subject: [PATCH] Add ImportPrivateIdentity to channels bindings --- bindings/channels.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bindings/channels.go b/bindings/channels.go index 07d34441c..98e746041 100644 --- a/bindings/channels.go +++ b/bindings/channels.go @@ -126,6 +126,23 @@ func GenerateChannelIdentity(cmixID int) ([]byte, error) { return pi.Marshal(), nil } +// ImportPrivateIdentity generates a new [channel.PrivateIdentity] from exported +// data. +// +// Parameters: +// - password - The password used to encrypt the identity. +// - data - The encrypted data. +// +// Returns: +// - JSON of [channel.PrivateIdentity]. +func ImportPrivateIdentity(password string, data []byte) ([]byte, error) { + pi, err := cryptoChannel.ImportPrivateIdentity(password, data) + if err != nil { + return nil, err + } + return pi.Marshal(), nil +} + // GetPublicChannelIdentity constructs a public identity ([channel.Identity]) // from a bytes version and returns it JSON marshaled. // -- GitLab