Skip to content

Commit

Permalink
docs: improved intro text and restore example
Browse files Browse the repository at this point in the history
restored bitcoin offline wallet example
  • Loading branch information
jaromil committed Oct 31, 2023
1 parent ddfd616 commit a206de2
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 19 deletions.
27 changes: 8 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,14 @@ SPDX-License-Identifier: AGPL-3.0-or-later

[![Zenroom logo](https://files.dyne.org/zenroom/logos/zenroom_logotype.png)](https://zenroom.org)

Zenroom is a **secure language interpreter** of the secure domain
specific language **Zencode**, it makes it very easy to execute fast
cryptographic operations on any data structure.

The Zenroom VM is very small, has **no external dependency**, is fully
deterministic and ready to run **end-to-end encryption** on any
platform: desktop, embedded, mobile, cloud micro-services, web
browsers. It can be embedded inside applications written in
Javascript, Python3, Rust or Golang.

**Zencode** is a domain-specific language (DSL) similar to human
language. With its **no-code** approach one can process large data
structures through complex cryptographic and logical
transformations.

Zencode helps us to lower the liability of developers by leveraging
the **agency of domain experts**: one can write and review business
logics and data-sensitive operations **without having to learn to
code**.
Zenroom is a **secure language interpreter** of the domain-specific Zencode, making it easy to execute fast cryptographic operations on any data structure.

The Zenroom VM is very small, has **no external dependency**, is fully deterministic and is ready to run **end-to-end encryption** on any platform: desktop, embedded mobile, cloud micro-services, and web browsers. Zenroom works inside applications written in Javascript, Python3, Rust or Golang.

Zencode has a **no-code** approach. It is a domain-specific language (DSL) **similar to human language**. One can process large data structures through complex cryptographic and logical transformations.

Zencode helps developers to **empower people** who know what to do with data: one can write and review business logic and data-sensitive operations **without learning to code**.


[![software by Dyne.org](https://files.dyne.org/software_by_dyne.png)](http://www.dyne.org)

Expand Down
6 changes: 6 additions & 0 deletions test/shell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Example use-cases using zenroom from shell code

This directory contains examples that are documented in on-line tutorials

- bitcoin_offline_wallet.sh :: [Bitcoin secure off-line wallet](https://medium.com/think-do-tank/bitcoin-secure-off-line-wallet-be50a57a8474)

85 changes: 85 additions & 0 deletions test/shell/bitcoin_offline_wallet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

# from the article on medium.com

. ../utils.sh $*
Z="`detect_zenroom_path` `detect_zenroom_conf`"

# sequenceDiagram
# participant SK as Secure off-line PC
# participant PK as Public on-line PC
# participant BC as Public blockchain explorer
# SK->>SK: keygen.txt
# SK-->>PK: copy public address
# PK->>+BC: send public address
# BC->>-PK: download unspent (UTXO)
# PK->>PK: create transaction: amount + recipient + UTXO
# PK-->>SK: copy transaction to sign
# SK->>SK: sign transaction offline
# SK-->>PK: copy signed transaction
# PK->>BC: broadcast signed transaction

cat << EOF | zexe keygen.zen | save bitcoin keys.json
Given nothing
When I create the testnet key
Then print the 'keyring'
EOF

cat <<EOF | zexe pubgen.zen -k keys.json | save bitcoin address.json
Given I have the 'keyring'
When I create the testnet address
Then print the 'testnet address'
EOF


addr=`cat address.json | jq '.testnet_address' | sed 's/\"//g'`

echo "curl -s https://blockstream.info/testnet/api/address/${addr}/utxo" | tee unspent_query.sh ../../docs/examples/zencode_cookbook/bitcoin/unspent_query.sh

# cat <<EOF | tee culo.json
# {
# "satoshi amount": "1",
# "satoshi fee": "141",
# "recipient": "tb1q73czlxl7us4s6num5sjlnq6r0yuf8uh5clr2tm",
# "sender": "${addr}",
# "satoshi unspent": `curl -s https://blockstream.info/testnet/api/address/${addr}/utxo`
# }
# EOF

cat <<EOF | tee transaction_data.json ../../docs/examples/zencode_cookbook/bitcoin/transaction_data.json
{
"satoshi amount": "1",
"satoshi fee": "141",
"recipient": "tb1q73czlxl7us4s6num5sjlnq6r0yuf8uh5clr2tm",
"sender": "${addr}"
}
EOF

cat <<EOF | tee unspent.json ../../docs/examples/zencode_cookbook/bitcoin/unspent.json
{
"satoshi unspent": `curl -s https://blockstream.info/testnet/api/address/${addr}/utxo`
}
EOF


jq -s '.[0] * .[1]' unspent.json transaction_data.json | save bitcoin order.json

cat <<EOF | zexe sign.zen -a order.json | save bitcoin transaction.json
Given I have a 'testnet address' named 'sender'
and I have a 'testnet address' named 'recipient'
and a 'satoshi fee'
and a 'satoshi amount'
and a 'satoshi unspent'
When I rename 'satoshi unspent' to 'testnet unspent'
and I create the testnet transaction
Then print the 'testnet transaction'
EOF

cat <<EOF | zexe sign_transaction.zen -k keys.json -a transaction.json | save bitcoin rawtx.json
Given I have the 'keyring'
and I have a 'base64 dictionary' named 'testnet transaction'
When I sign the testnet transaction
and I create the testnet raw transaction
and I create the size of 'testnet raw transaction'
Then print the 'testnet raw transaction' as 'hex'
EOF

0 comments on commit a206de2

Please sign in to comment.