diff --git a/src/groupNoble.ts b/src/groupNoble.ts index a2365b6..eb9e628 100644 --- a/src/groupNoble.ts +++ b/src/groupNoble.ts @@ -301,21 +301,14 @@ class GroupNb implements Group { return ScalarNb.hash(this, msg, dst) } - eltDes: Deserializer = { - size: (compressed?: boolean) => { - return this.eltSize(compressed) - }, - deserialize: (b: Uint8Array) => { - return this.desElt(b) - } + readonly eltDes: Deserializer = { + size: (compressed) => this.eltSize(compressed), + deserialize: (b) => this.desElt(b) } - scalarDes: Deserializer = { - size: () => { - return this.scalarSize() - }, - deserialize: (b: Uint8Array) => { - return this.desScalar(b) - } + + readonly scalarDes: Deserializer = { + size: () => this.scalarSize(), + deserialize: (b) => this.desScalar(b) } desElt(bytes: Uint8Array): EltNb { diff --git a/src/groupSjcl.ts b/src/groupSjcl.ts index b434702..250bf71 100644 --- a/src/groupSjcl.ts +++ b/src/groupSjcl.ts @@ -6,7 +6,16 @@ import { checkSize, joinAll, xor } from './util.js' import sjcl from './sjcl/index.js' -import { Elt, errBadGroup, Group, GroupCons, GroupID, GroupIDs, Scalar } from './groupTypes.js' +import { + Deserializer, + Elt, + errBadGroup, + Group, + GroupCons, + GroupID, + GroupIDs, + Scalar +} from './groupTypes.js' function errDeserialization(T: { name: string }) { return new Error(`group: deserialization of ${T.name} failed.`) @@ -530,25 +539,17 @@ class GroupSj implements Group { return ScalarSj.hash(this, msg, dst) } - get eltDes() { + get eltDes(): Deserializer { return { - size: (compressed?: boolean): number => { - return EltSj.size(this, compressed) - }, - deserialize: (b: Uint8Array): EltSj => { - return EltSj.deserialize(this, b) - } + size: (compressed): number => EltSj.size(this, compressed), + deserialize: (b) => EltSj.deserialize(this, b) } } - get scalarDes() { + get scalarDes(): Deserializer { return { - size: (): number => { - return ScalarSj.size(this) - }, - deserialize: (b: Uint8Array): ScalarSj => { - return ScalarSj.deserialize(this, b) - } + size: () => ScalarSj.size(this), + deserialize: (b) => ScalarSj.deserialize(this, b) } }