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); } }
/** * Build a new session from a received {@link PreKeySignalMessage}. * * After a session is constructed in this way, the embedded {@link SignalMessage} * can be decrypted. * * @param message The received {@link PreKeySignalMessage}. * @throws org.whispersystems.libsignal.InvalidKeyIdException when there is no local * {@link org.whispersystems.libsignal.state.PreKeyRecord} * that corresponds to the PreKey ID in * the message. * @throws org.whispersystems.libsignal.InvalidKeyException when the message is formatted incorrectly. * @throws org.whispersystems.libsignal.UntrustedIdentityException when the {@link IdentityKey} of the sender is untrusted. */ /*package*/ internal May <uint> process(SessionRecord sessionRecord, PreKeySignalMessage message) { uint messageVersion = message.getMessageVersion(); IdentityKey theirIdentityKey = message.getIdentityKey(); if (!identityKeyStore.IsTrustedIdentity(remoteAddress.getName(), theirIdentityKey)) { throw new UntrustedIdentityException(remoteAddress.getName(), theirIdentityKey); } May <uint> unsignedPreKeyId = processV3(sessionRecord, message); identityKeyStore.SaveIdentity(remoteAddress.getName(), theirIdentityKey); return(unsignedPreKeyId); }
public IdentityKeyPair(IdentityKey publicKey, ECPrivateKey privateKey) { this.publicKey = publicKey; this.privateKey = privateKey; }