Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@chainsafe/ssz
Advanced tools
Simple Serialize (SSZ)
npm install @chainsafe/ssz
See our autogenerated API docs
In order to properly serialize/deserialize/hash values, we need both the value and the "type" of the value.
The simple serialization spec operates over a few specific types.
Types are either specified in a simplified form (eg: "uint32"
) or an extended form
(eg: {type: Type.uint, byteLength: 4, offset: 0, useNumber: false}
). In most cases, the simplified form suffices.
A uint serialization value may be either a js number
or a BN
from bn.js.
A uint type is specified by either "uintN"
or "numberN"
, where N is the number of bits to serialize.
uintN
> 48 bits is deserialized to a BN
else deserialized to a number
.
Every numberN
is deserialized to a number.
A boolean serialization value must be either true
or false
. Anything other input will throw an Error
.
The boolean type is specified as "bool"
.
A "vector" according to the spec is a fixed-length list with every element of the same type.
A vector serialization value may be either an Array
or Buffer
.
Vector types are specified as either "bytesN"
or [elementType, vectorlength]
bytesN
is deserialized to Buffer
.
[elementType, vectorLength]
is deserialized to Array<elementType>
unless elementType is byte
, when the value is deserialized to Buffer
.
A "list" according to the spec is a list of unspecified length with every element of the same type.
A list serialization value may be either an Array
or Buffer
.
Tuple types are specified as either "bytes"
or [elementType]
bytes
is deserialized to Buffer
.
[elementType]
is deserialized to Array<elementType>
unless elementType is byte
, when the value is deserialized to Buffer
.
A "container" according to the spec is a collection of values where the type of each element may differ.
A container serialization value must be an Object
.
The container serialization type must be an Object
, with a string name
, and a fields
value of `Array<[fieldName, fieldType]>.
See FullSSZType
in src/types.ts
for more information.
Apache 2.0
FAQs
Simple Serialize
The npm package @chainsafe/ssz receives a total of 83,060 weekly downloads. As such, @chainsafe/ssz popularity was classified as popular.
We found that @chainsafe/ssz demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.