Skip to content

Commit

Permalink
feat: Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
Iskander508 authored and Pavel Zarecky committed Jan 25, 2022
0 parents commit 1f89970
Show file tree
Hide file tree
Showing 11 changed files with 12,740 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
48 changes: 48 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI
env:
CI: true

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
ci:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Read Node.js version to install from `.nvmrc`
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvm
- name: Install required Node.js version
uses: actions/setup-node@v1
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
- name: Get Yarn cache directory path
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Setup cache key and directory for node_modules cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Yarn install
run: yarn --frozen-lockfile
- name: Test
run: yarn test --coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Release
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next')
run: yarn semantic-release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# dependencies
/node_modules/

# misc
.DS_Store
/dist/
TODO

# test
/coverage/

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json

.env
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.18.2
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Pavel Zarecky

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# ed448-js [![GitHub license](https://img.shields.io/github/license/Iskander508/Ed448-js?style=flat)](https://github.com/Iskander508/Ed448-js/blob/master/LICENSE) [![Tests](https://github.com/Iskander508/Ed448-js/workflows/CI/badge.svg)](https://github.com/Iskander508/Ed448-js/actions) [![npm version][npm-img]][npm-url] [![Coverage Status][coveralls-img]][coveralls-url] [![Monthly Downloads][downloads-img]][downloads-url]

[npm-url]: https://www.npmjs.com/package/ed448-js
[npm-img]: https://img.shields.io/npm/v/ed448-js
[coveralls-url]: https://coveralls.io/github/Iskander508/Ed448-js?branch=master
[coveralls-img]: https://coveralls.io/repos/Iskander508/Ed448-js/badge.svg?branch=master&service=github
[downloads-url]: https://www.npmjs.com/package/ed448-js
[downloads-img]: https://img.shields.io/npm/dm/ed448-js.svg

Pure JavaScript/TypeScript implementation of the Ed448 elliptic curve (RFC 8032) for EdDSA signature. Uses the `jsbn` library for big integer operations. Uses `jssha` for `SHAKE256` hash calculation.

## Installation

Using `npm`:

npm install ed448-js

or `yarn`:

yarn add ed448-js

Then include it in your code:

```ts
import createEd448 from "ed448-js";
```

## Usage

```ts
const Ed448 = createEd448();
```

### `getPublicKey(privateKey)`

Calculate public key from a provided private key

```ts
const privateKey = Array.from(crypto.randomFillSync(new Uint8Array(57)));
const publicKey = Ed448.getPublicKey(privateKey);
```

The private key can be any random generated byte-array of length 57

### `sign(privateKey, publicKey, message, context?): number[]`

Calculate the EdDSA signature.
The result is represented as plain number array (length: 114). It can be converted using `Buffer.from`, or `Uint8Array.from`.

### `verify(publicKey, message, signature, context?): boolean`

Verify the EdDSA signature.
108 changes: 108 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"name": "ed448-js",
"version": "0.0.0-development",
"private": false,
"description": "Pure JS/TS library with Ed448 for EdDSA",
"keywords": [
"Ed448",
"EdDSA"
],
"repository": {
"type": "git",
"url": "https://github.com/Iskander508/Ed448-js.git"
},
"license": "MIT",
"author": "Pavel Zarecky <zarecky@procivis.ch>",
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/ed448-js.esm.js",
"typings": "dist/index.d.ts",
"files": [
"src/",
"dist/",
"LICENSE",
"README.md"
],
"scripts": {
"build": "tsdx build",
"format": "tsdx lint src --fix",
"lint": "tsdx lint src",
"prepare": "tsdx build",
"semantic-release": "semantic-release",
"start": "tsdx watch",
"test": "tsdx test"
},
"prettier": {
"trailingComma": "all"
},
"dependencies": {
"jsbn": "^1.1.0",
"jssha": "^3.2.0"
},
"devDependencies": {
"@types/jsbn": "^1.2.30",
"@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-jest": "25.0.1",
"prettier-plugin-packagejson": "2.2.13",
"semantic-release": "^19.0.2",
"semantic-release-cli": "5.4.4",
"tsdx": "0.14.1",
"tslib": "2.3.1",
"typescript": "4.4.4"
},
"peerDependencies": {},
"eslint": {
"env": {
"es6": true,
"jest": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"extends": [
"eslint:recommended",
"plugin:jest/recommended",
"plugin:import/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"curly": "error",
"import/order": [
"error",
{
"newlines-between": "always"
}
]
},
"settings": {
"import/extensions": [
".ts"
],
"import/resolver": {
"node": {
"extensions": [
".ts"
]
}
}
}
},
"renovate": {
"extends": [
"config:js-lib",
":automergePatch",
":automergeBranch",
":automergePatch",
":automergeBranch",
":automergeLinters",
":automergeTesters",
":automergeTypes"
]
}
}
Loading

0 comments on commit 1f89970

Please sign in to comment.