public byte[] serialize() { return(IdentityKeyPairStructure.CreateBuilder() .SetPublicKey(ByteString.CopyFrom(publicKey.serialize())) .SetPrivateKey(ByteString.CopyFrom(privateKey.serialize())) .Build().ToByteArray()); }
public IdentityKeyPair(byte[] serialized) { try { IdentityKeyPairStructure structure = IdentityKeyPairStructure.ParseFrom(serialized); this.publicKey = new IdentityKey(structure.PublicKey.ToByteArray(), 0); this.privateKey = Curve.decodePrivatePoint(structure.PrivateKey.ToByteArray()); } catch (InvalidProtocolBufferException e) { throw new InvalidKeyException(e); } }