Example #1
0
  public NorvosPreKeyStore(byte[] serialized) throws IOException {
    PreKeyStoreStructure struct = PreKeyStoreStructure.parseFrom(serialized);
    oneTimePreKeys = new CircularBuffer<PreKeyRecord>(Medium.MAX_VALUE);

    for (PreKeyStructure protoMessage : struct.getOneTimePreKeyList()) {
      PreKeyRecord key = new PreKeyRecord(protoMessage.getPreKeyRecord().toByteArray());
      oneTimePreKeys.add(protoMessage.getKeyId(), key);
    }
  }
Example #2
0
  public synchronized byte[] serialize() {
    Builder builder = PreKeyStoreStructure.newBuilder();
    for (PreKeyRecord entry : oneTimePreKeys.getAll()) {
      PreKeyStructure struct =
          PreKeyStructure.newBuilder()
              .setKeyId(entry.getId())
              .setPreKeyRecord(ByteString.copyFrom(entry.serialize()))
              .build();
      builder.addOneTimePreKey(struct);
    }

    return builder.build().toByteArray();
  }