public IdentityKeyPair(byte[] serialized) { try { IdentityKeyPairStructure structure = IdentityKeyPairStructure.Parser.ParseFrom(serialized); _publicKey = new IdentityKey(structure.PublicKey.ToByteArray(), 0); _privateKey = Curve.DecodePrivatePoint(structure.PrivateKey.ToByteArray()); } catch (InvalidProtocolBufferException e) { throw new InvalidKeyException(e); } }
/// <summary> /// Build a new session from a received {@link PreKeySignalMessage}. /// After a session is constructed in this way, the embedded {@link SignalMessage} /// can be decrypted. /// </summary> /// <param name="message">The received {@link PreKeySignalMessage}.</param> /// <exception cref="InvalidKeyIdException">when there is no local {@link org.whispersystems.libsignal.state.PreKeyRecord} that corresponds to the PreKey ID in the message.</exception> /// <exception cref="InvalidKeyException">when the message is formatted incorrectly.</exception> /// <exception cref="UntrustedIdentityException">when the {@link IdentityKey} of the sender is untrusted.</exception> /// /*package*/ internal May <uint> Process(SessionRecord sessionRecord, PreKeySignalMessage message) { uint messageVersion = message.GetMessageVersion(); IdentityKey theirIdentityKey = message.GetIdentityKey(); if (!_identityKeyStore.IsTrustedIdentity(_remoteAddress, theirIdentityKey, Direction.Receiving)) { throw new UntrustedIdentityException(_remoteAddress.Name, theirIdentityKey); } May <uint> unsignedPreKeyId = ProcessV3(sessionRecord, message); _identityKeyStore.SaveIdentity(_remoteAddress, theirIdentityKey); return(unsignedPreKeyId); }
public UntrustedIdentityException(String name, IdentityKey key) { _name = name; _key = key; }
public IdentityKeyPair(IdentityKey publicKey, IEcPrivateKey privateKey) { _publicKey = publicKey; _privateKey = privateKey; }