Skip to content

Commit 6ce6e40

Browse files
authored
fix: fixes a bug in Ed25519KeyIdentity toRaw where the output was not an ArrayBuffer (#995)
1 parent c51b689 commit 6ce6e40

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
### Changed
77

8+
- fix: fixes a bug in Ed25519KeyIdentity `toRaw` where the output was not an ArrayBuffer
89
- test: fixes e2e tests for compatibility with dfx 0.26.0 and `pocket-ic` by querying for the `default_effective_canister_id` before calling the management canister
910
- fix: fixes a bug in the Ed25519KeyIdentity verify implementation where the argument order was incorrect
1011
- fix: fixes a bug in the `Principal` library where the management canister id util was incorrectly importing using `fromHex`

packages/agent/src/agent/http/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import { Ed25519PublicKey } from '../../public_key';
4848
import { decodeTime } from '../../utils/leb';
4949
import { ObservableLog } from '../../observable';
5050
import { BackoffStrategy, BackoffStrategyFactory, ExponentialBackoff } from '../../polling/backoff';
51-
import { DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS } from '../../constants';
5251
export * from './transforms';
5352
export * from './errors';
5453
export { Nonce, makeNonce } from './types';
@@ -981,7 +980,7 @@ export class HttpAgent implements Agent {
981980
}
982981
const { status, signatures = [], requestId } = queryResponse;
983982

984-
const domainSeparator = new TextEncoder().encode('\x0Bic-response');
983+
const domainSeparator = bufFromBufLike(new TextEncoder().encode('\x0Bic-response'));
985984
for (const sig of signatures) {
986985
const { timestamp, identity } = sig;
987986
const nodeId = Principal.fromUint8Array(identity).toText();
@@ -1010,7 +1009,7 @@ export class HttpAgent implements Agent {
10101009
throw new Error(`Unknown status: ${status}`);
10111010
}
10121011

1013-
const separatorWithHash = concat(domainSeparator, new Uint8Array(hash));
1012+
const separatorWithHash = concat(domainSeparator, bufFromBufLike(new Uint8Array(hash)));
10141013

10151014
// FIX: check for match without verifying N times
10161015
const pubKey = subnetStatus?.nodeKeys.get(nodeId);
@@ -1080,7 +1079,7 @@ export class HttpAgent implements Agent {
10801079
function getRequestId(fields: ReadStateOptions): RequestId | undefined {
10811080
for (const path of fields.paths) {
10821081
const [pathName, value] = path;
1083-
const request_status = new TextEncoder().encode('request_status');
1082+
const request_status = bufFromBufLike(new TextEncoder().encode('request_status'));
10841083
if (bufEquals(pathName, request_status)) {
10851084
return value as RequestId;
10861085
}

packages/identity/src/identity/ed25519.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class Ed25519PublicKey implements PublicKey {
7373
if (unwrapped.length !== this.RAW_KEY_LENGTH) {
7474
throw new Error('An Ed25519 public key must be exactly 32bytes long');
7575
}
76-
return unwrapped;
76+
return bufFromBufLike(unwrapped);
7777
}
7878

7979
#rawKey: ArrayBuffer;
@@ -93,7 +93,7 @@ export class Ed25519PublicKey implements PublicKey {
9393
if (key.byteLength !== Ed25519PublicKey.RAW_KEY_LENGTH) {
9494
throw new Error('An Ed25519 public key must be exactly 32bytes long');
9595
}
96-
this.#rawKey = key;
96+
this.#rawKey = bufFromBufLike(key);
9797
this.#derKey = Ed25519PublicKey.derEncode(key);
9898
}
9999

0 commit comments

Comments
 (0)