comparePublicKeys method

int comparePublicKeys (_Pubkey a, _Pubkey b)

Implementation

static int comparePublicKeys(_Pubkey a, _Pubkey b) {
  if (a.algo != b.algo) {
    return a.algo - b.algo;
  }

  if (a.algo == KeyType.ecdsa.value || a.algo == KeyType.sm2.value) {
    int cx = a.x.compareTo(b.x);
    if (cx != 0) return cx;
    return a.y.compareTo(b.y);
  }

  int aa = Buffer.fromBytes(a.raw).readUint64(ofst: 0);
  int bb = Buffer.fromBytes(b.raw).readUint64(ofst: 0);
  if (aa == bb) return 0;
  if (aa > bb) return 1;
  return -1;
}