registerPublicKey method

bool registerPublicKey(
  1. String peerId,
  2. Uint8List publicKeyBytes
)

Registers publicKeyBytes for peerId after verifying cryptographic binding.

Returns true if the binding is valid and registered, false otherwise.

Implementation

bool registerPublicKey(String peerId, Uint8List publicKeyBytes) {
  if (!verifyPeerBinding(peerId, publicKeyBytes)) {
    return false;
  }
  if (!_keys.containsKey(peerId) && _keys.length >= maxRegisteredKeys) {
    _keys.remove(_keys.keys.first);
  }
  _keys[peerId] = Uint8List.fromList(publicKeyBytes);
  return true;
}