-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
417 additions
and
76 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
// Version of the setting file. Always 0.2 | ||
"version": "0.2", | ||
// language - current active spelling language | ||
"language": "en", | ||
// words - list of words to be always considered correct | ||
"words": ["bindgen", "ecies", "eciesrs", "keypair"], | ||
// flagWords - list of words to be always considered incorrect | ||
// This is useful for offensive words and common spelling errors. | ||
// For example "hte" should be "the" | ||
"flagWords": ["hte"], | ||
"ignorePaths": [ | ||
".git", | ||
".github", | ||
".gitignore", | ||
".cspell.jsonc", | ||
"LICENSE", | ||
"package.json", | ||
"yarn.lock" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,10 @@ Cargo.lock | |
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
|
||
.DS_Store | ||
|
||
# js stuff | ||
node_modules/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
{ | ||
"spellright.language": ["en"], | ||
"spellright.documentTypes": ["markdown", "latex", "plaintext", "toml"], | ||
"rust-analyzer.cargo.target": "wasm32-unknown-unknown", | ||
"spellright.ignoreFiles": [ | ||
"~/.cargo/", | ||
"~/.rustup/", | ||
"**/.gitignore", | ||
"**/.spellignore" | ||
] | ||
"rust-analyzer.cargo.target": "wasm32-unknown-unknown" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Changelog | ||
|
||
## 0.2.0 | ||
|
||
- Reduce wasm size from 1.2MB to ~100KB by revamping the build process | ||
- Rename `generate_keypair` to `generateKeypair` to follow JavaScript convention | ||
- Revamp wasm example to use vite instead of webpack | ||
- Revamp wasm build package to build web target | ||
- Bump dependencies | ||
|
||
## 0.1.2 | ||
- Bump dependencies | ||
|
||
## 0.1.1 | ||
|
||
- Expose `generate_keypair` | ||
- Revamp doc | ||
|
||
## 0.1.0 | ||
|
||
- First beta release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# wasm example | ||
|
||
## Install | ||
|
||
`yarn install` | ||
|
||
## Run dev server | ||
|
||
`yarn dev` | ||
|
||
## Build and preview | ||
|
||
`yarn build && yarn preview` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Hello ecies</title> | ||
</head> | ||
|
||
<body> | ||
<main id="app"></main> | ||
<noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript> | ||
<script type="module" src="./index.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// need to build with `wasm-pack build --target web` | ||
import init, * as ecies from "../pkg/ecies_wasm"; | ||
|
||
init(); | ||
|
||
const data = Uint8Array.from([1, 2, 3, 4]); | ||
|
||
function checkOk() { | ||
const [sk, pk] = ecies.generateKeypair(); | ||
|
||
const encrypted = ecies.encrypt(pk, data); | ||
const decrypted = ecies.decrypt(sk, encrypted); | ||
alert(`decrypted: ${decrypted}`); | ||
if (decrypted.toString("hex") === data.toString("hex")) { | ||
alert("call wasm encrypt decrypt ok"); | ||
} | ||
} | ||
|
||
function checkError() { | ||
const pk = Uint8Array.from([0]); | ||
try { | ||
ecies.encrypt(pk, data); | ||
} catch (e) { | ||
alert(e); | ||
} | ||
} | ||
|
||
document.querySelector("#app").innerHTML = ` | ||
<h1>WASM Test</h1> | ||
<button id="ok">Check ok</button> | ||
<button id="error">Check error</button> | ||
`; | ||
|
||
document.getElementById("ok").addEventListener("click", () => { | ||
checkOk(); | ||
}); | ||
document.getElementById("error").addEventListener("click", () => { | ||
checkError(); | ||
}); | ||
|
||
window.addEventListener("error", (event) => { | ||
// catch all other errors | ||
console.error(event); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "ecies-wasm-example", | ||
"version": "0.1.0", | ||
"author": "Weiliang Li <to.be.impressive@gmail.com>", | ||
"description": "ecies-wasm in browser", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"type": "module", | ||
"repository": { | ||
"url": "https://github.com/ecies/rs" | ||
}, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"vite": "^4.4.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from "vite"; | ||
|
||
export default defineConfig({ | ||
server: { | ||
fs: { | ||
// Allow serving files from one level up to the project root | ||
allow: [".."], | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.