diff --git a/src/characters/pre-recipient.ts b/src/characters/pre-recipient.ts index f321c34cb..f9fe4270b 100644 --- a/src/characters/pre-recipient.ts +++ b/src/characters/pre-recipient.ts @@ -13,7 +13,7 @@ import { Keyring } from '../keyring'; import { PolicyMessageKit } from '../kits/message'; import { RetrievalResult } from '../kits/retrieval'; import { PorterClient } from '../porter'; -import { base64ToU8Receiver, bytesEquals, toJSON, zip } from '../utils'; +import { base64ToU8Receiver, toJSON, zip } from '../utils'; export type PreDecrypterJSON = { porterUri: string; @@ -185,15 +185,11 @@ export class PreDecrypter { } public equals(other: PreDecrypter): boolean { - return ( - this.porter.porterUrl.toString() === other.porter.porterUrl.toString() && - this.policyEncryptingKey.equals(other.policyEncryptingKey) && - // TODO: Replace with `equals` after https://github.com/nucypher/nucypher-core/issues/56 is fixed - bytesEquals( - this.encryptedTreasureMap.toBytes(), - other.encryptedTreasureMap.toBytes() - ) && - this.publisherVerifyingKey.equals(other.publisherVerifyingKey) - ); + return [ + this.porter.porterUrl.toString() === other.porter.porterUrl.toString(), + this.policyEncryptingKey.equals(other.policyEncryptingKey), + this.encryptedTreasureMap.equals(other.encryptedTreasureMap), + this.publisherVerifyingKey.equals(other.publisherVerifyingKey), + ].every(Boolean); } } diff --git a/src/conditions/condition-expr.ts b/src/conditions/condition-expr.ts index 5cc032c5e..61c446e53 100644 --- a/src/conditions/condition-expr.ts +++ b/src/conditions/condition-expr.ts @@ -95,9 +95,9 @@ export class ConditionExpression { } public equals(other: ConditionExpression): boolean { - return ( - this.version === other.version && - objectEquals(this.condition.toObj(), other.condition.toObj()) - ); + return [ + this.version === other.version, + objectEquals(this.condition.toObj(), other.condition.toObj()), + ].every(Boolean); } } diff --git a/src/dkg.ts b/src/dkg.ts index 16208ebcd..2201d7df7 100644 --- a/src/dkg.ts +++ b/src/dkg.ts @@ -9,7 +9,7 @@ import { import { ethers } from 'ethers'; import { DkgCoordinatorAgent } from './agents/coordinator'; -import { bytesEquals, fromHexString } from './utils'; +import { fromHexString } from './utils'; // TODO: Expose from @nucypher/nucypher-core export enum FerveoVariant { @@ -75,12 +75,11 @@ export class DkgRitual { } public equals(other: DkgRitual): boolean { - return ( - this.id === other.id && - // TODO: Replace with `equals` after https://github.com/nucypher/nucypher-core/issues/56 is fixed - bytesEquals(this.dkgPublicKey.toBytes(), other.dkgPublicKey.toBytes()) && - this.threshold === other.threshold - ); + return [ + this.id === other.id, + this.dkgPublicKey.equals(other.dkgPublicKey), + this.threshold === other.threshold, + ].every(Boolean); } } diff --git a/src/sdk/strategy/cbd-strategy.ts b/src/sdk/strategy/cbd-strategy.ts index b53dac400..62440881f 100644 --- a/src/sdk/strategy/cbd-strategy.ts +++ b/src/sdk/strategy/cbd-strategy.ts @@ -1,7 +1,6 @@ import { DkgPublicKey } from '@nucypher/nucypher-core'; import { ethers } from 'ethers'; -import { bytesEqual } from '../../../test/utils'; import { ThresholdDecrypter, ThresholdDecrypterJSON, @@ -110,9 +109,9 @@ export class DeployedCbdStrategy { } public equals(other: DeployedCbdStrategy) { - return ( - this.decrypter.equals(other.decrypter) && - bytesEqual(this.dkgPublicKey.toBytes(), other.dkgPublicKey.toBytes()) - ); + return [ + this.decrypter.equals(other.decrypter), + this.dkgPublicKey.equals(other.dkgPublicKey), + ].every(Boolean); } } diff --git a/src/sdk/strategy/pre-strategy.ts b/src/sdk/strategy/pre-strategy.ts index 0ef97681d..51d883cea 100644 --- a/src/sdk/strategy/pre-strategy.ts +++ b/src/sdk/strategy/pre-strategy.ts @@ -131,20 +131,20 @@ export class PreStrategy { } public equals(other: PreStrategy) { - return ( - this.cohort.equals(other.cohort) && - // TODO: Replace with `equals` after https://github.com/nucypher/nucypher-core/issues/56 is fixed + return [ + this.cohort.equals(other.cohort), + // TODO: Replace with `equals` after https://github.com/nucypher/rust-umbral/pull/125 is released bytesEquals( this.aliceSecretKey.toBEBytes(), other.aliceSecretKey.toBEBytes() - ) && + ), bytesEquals( this.bobSecretKey.toBEBytes(), other.bobSecretKey.toBEBytes() - ) && - this.startDate.toString() === other.startDate.toString() && - this.endDate.toString() === other.endDate.toString() - ); + ), + this.startDate.toString() === other.startDate.toString(), + this.endDate.toString() === other.endDate.toString(), + ].every(Boolean); } } @@ -203,10 +203,10 @@ export class DeployedPreStrategy { } public equals(other: DeployedPreStrategy) { - return ( - this.cohort.equals(other.cohort) && - this.decrypter.equals(other.decrypter) && - this.policyKey.equals(other.policyKey) - ); + return [ + this.cohort.equals(other.cohort), + this.decrypter.equals(other.decrypter), + this.policyKey.equals(other.policyKey), + ].every(Boolean); } }