100% found this document useful (1 vote)
13 views

Introducing Blockchain with Java: Program, Implement, and Extend Blockchains with Java 1st Edition Spiro Buzharovski - The complete ebook is available for download with one click

The document provides an overview of blockchain technology and its implementation using Java, highlighting key concepts such as ledgers, peer-to-peer networks, digital signatures, and encryption methods. It introduces the foundational definitions and problems associated with blockchain, including double-spending and trust issues, while also outlining the transition from a centralized to a decentralized ledger system. Additionally, it touches on encryption techniques, specifically symmetric and asymmetric algorithms, as essential components of securing blockchain transactions.

Uploaded by

junrelmanibo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
13 views

Introducing Blockchain with Java: Program, Implement, and Extend Blockchains with Java 1st Edition Spiro Buzharovski - The complete ebook is available for download with one click

The document provides an overview of blockchain technology and its implementation using Java, highlighting key concepts such as ledgers, peer-to-peer networks, digital signatures, and encryption methods. It introduces the foundational definitions and problems associated with blockchain, including double-spending and trust issues, while also outlining the transition from a centralized to a decentralized ledger system. Additionally, it touches on encryption techniques, specifically symmetric and asymmetric algorithms, as essential components of securing blockchain transactions.

Uploaded by

junrelmanibo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

Introducing Blockchain with Java: Program,


Implement, and Extend Blockchains with Java 1st
Edition Spiro Buzharovski

https://ebookmeta.com/product/introducing-blockchain-with-
java-program-implement-and-extend-blockchains-with-java-1st-
edition-spiro-buzharovski-2/

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Introducing Blockchain with Java: Program, Implement, and


Extend Blockchains with Java 1st Edition Spiro Buzharovski

https://ebookmeta.com/product/introducing-blockchain-with-java-
program-implement-and-extend-blockchains-with-java-1st-edition-spiro-
buzharovski/
ebookmeta.com

Introducing Blockchain with Lisp: Implement and Extend


Blockchains with the Racket Language 1st Edition Boro
Sitnikovski
https://ebookmeta.com/product/introducing-blockchain-with-lisp-
implement-and-extend-blockchains-with-the-racket-language-1st-edition-
boro-sitnikovski/
ebookmeta.com

Learn Java with Math 1st Edition Ron Dai

https://ebookmeta.com/product/learn-java-with-math-1st-edition-ron-
dai/

ebookmeta.com

Statistics of Earth Science Data Their Distribution in


Time Space and Orientation 2nd Edition Graham J Borradaile

https://ebookmeta.com/product/statistics-of-earth-science-data-their-
distribution-in-time-space-and-orientation-2nd-edition-graham-j-
borradaile/
ebookmeta.com
Rethinking darkness cultures histories practices 1st
Edition Nick Dunn Editor Tim Edensor Editor

https://ebookmeta.com/product/rethinking-darkness-cultures-histories-
practices-1st-edition-nick-dunn-editor-tim-edensor-editor-2/

ebookmeta.com

Junkyard Blues 1st Edition Al Moye

https://ebookmeta.com/product/junkyard-blues-1st-edition-al-moye/

ebookmeta.com

Marketing: An Introduction, 15th Global Edition Gary


Armstrong

https://ebookmeta.com/product/marketing-an-introduction-15th-global-
edition-gary-armstrong/

ebookmeta.com

Spectacular Sports World s Toughest Races Understanding


Fractions Saskia Lacey

https://ebookmeta.com/product/spectacular-sports-world-s-toughest-
races-understanding-fractions-saskia-lacey/

ebookmeta.com

The Grey Eagles of Chippewa Falls 1st Edition John E


Kinville

https://ebookmeta.com/product/the-grey-eagles-of-chippewa-falls-1st-
edition-john-e-kinville/

ebookmeta.com
The Protocol of the Gods A Study of the Kasuga Cult in
Japanese History Allan G. Grapard

https://ebookmeta.com/product/the-protocol-of-the-gods-a-study-of-the-
kasuga-cult-in-japanese-history-allan-g-grapard/

ebookmeta.com
CHAPTER 1

Introduction

to Blockchain

The entirety of this chapter is comprised of an excerpt from


Introducing Blockchain with Lisp: Implement and Extend Blockchains
with the Racket Language by Boro Sitnikovski, and it is reused here
with the author’s permission.

“Chained” by Filip Rizov

© Spiro Buzharovski 2022


1

S. Buzharovski, Introducing Blockchain with Java,

https://doi.org/10.1007/978-1-4842-7927-4_1

Chapter 1 IntroduCtIon to BloCkChaIn

In this chapter, we will see some definitions and examples for


blockchain. We will see what properties a blockchain has, what it
allows us to do, and what it is good for.

Definition 1-1 Blockchain is a system in which a record of


transactions is maintained across several computers that are linked in
a peer-to-peer network.1

We will give an example that will serve as motivation, as well as


define what encryption and hashing techniques are and how they will
help us with our system.

Note that we will skip some of the technical bits in this chapter, as it
is only supposed to serve as introductory material. The technical bits
will be covered later when we start building the blockchain.

1.1 Motivation and Basic Definitions

Let’s assume that you and your friends exchange money often, for
example, paying for dinner or drinks. It can be inconvenient to
exchange cash all the time.

One possible solution is to keep records of all the bills that you and
your friends have. This is called a ledger and is depicted in Figure 1-
1.
1 We will use this definition throughout the book, but note that there
are many different definitions on the Internet. By the end of this
book, you should be able to distinguish the slight nuances and
similarities in each definition.

Chapter 1 IntroduCtIon to BloCkChaIn

Figure 1-1. A ledger and a set of connected friends (peers)


Definition 1-2 a

ledger is a book that contains a record of

transactions.

Further, at the end of every day, you all sit together and refer to the
ledger to do the calculations to settle up. Let’s imagine that there is a
pot that is the place where all of the money is kept. If you spent
more than you received, you put that money in the pot; otherwise,
you take that money out.

We want to design the system such that it functions similarly to a


regular bank account. A holder of a wallet (bank account) should be
able to only send money from their wallet to other wallets. Thus,
every person in the system will have a wallet of a kind, which can
also be used to determine the balance for them. Note that with the
current setup using a ledger, we have to go through all the existing
records to determine the balance of a specific wallet.

If we want to avoid going through all the existing records, there is a


way we can optimize this with unspent transaction outputs (UTXOs),
as we will see later in Chapter 3.

Chapter 1 IntroduCtIon to BloCkChaIn

A problem that may arise is the double-spending problem, where Bob


can try to send all of his money to Alice and you at the same time,
thus effectively doubling the money he sends in relation to what he
owned.

There are several ways this can be resolved, and the solution that we
will provide will be a simple check of the sum of the inputs and the
sum of the outputs.

A problem that might appear with this kind of system is that anyone
can add a transaction. For example, Bob can add a transaction where
Alice pays him a few dollars without Alice’s approval. We need to re-
think our system such that each transaction will have a way to be
verified/signed.

Definition 1-3 a

digital signature is a way to verify the

authenticity of digital messages or documents.

For signing and verifying transactions we will rely on digital


signatures (Figure 1-2). For now, let’s assume that anyone who adds
information to the ledger also adds a signature with each record, and
others have no way to modify the signature, but only to verify it. We
will cover the technical details in the “Encryption” section.

Figure 1-2. Our ledger now contains signatures 4

Chapter 1 IntroduCtIon to BloCkChaIn

However, let’s assume that Bob is keeping the ledger to himself, and
everybody agrees to this. The ledger is now stored in what is a
centralized place. But in this case, if Bob is unavailable at the end of
the day when everybody gathers to settle up, nobody will be able to
refer to the ledger.

We need a way to decentralize the ledger, such that at any given time
any of the people can do a transaction. For this, every person
involved will keep a copy of the ledger to themselves, and when they
meet at the end of the day, they will sync their ledgers.

You are connected to your friends, and so are they to you. Informally,
this makes a peer-to-peer network.

Definition 1-4 a
peer-to-peer network is formed when two or

more computers are connected to each other.

For example, when you are accessing a web page on the Internet
using a browser, your browser is the client, and the web page you’re
accessing is hosted by a server. This represents a centralized system
since every user is getting the information from a single place—the
server.

In contrast, in a peer-to-peer network, which represents a


decentralized system, the distinction between a client and a server is
blurred. Every peer is both a client and a server at the same time.

With the system (Figure 1-3), as the list of peers (people) grows, we
might run into a problem of trust. When everybody meets at the end
of the day to sync their ledgers, how can they believe the others that
the transactions listed in their ledgers are true? Even if everybody
trusts everybody else for their ledger, what if a new person wants to
join this network? It’s natural for existing users to ask this newcomer
to prove that they can be trusted. We need to modify our system to
support this kind of trust. One way to achieve that is through so-
called proof of work, which we introduce next.

5
Chapter 1 IntroduCtIon to BloCkChaIn

Figure 1-3. A decentralized ledger

Definition 1-5 a

proof of work is data that is time-consuming to calculate and easy for


others to verify.

For each record we will also include a special number (or a hash) that
will represent proof of work, in that it will provide proof that the
transaction is valid. We will cover the technical details in the
“Hashing”

section.
At the end of the day, we agree that we will trust the ledger of the
person who has put most of the work in it. If Bob has some errands
to run, he can catch up the next day by trusting the rest of the peers
in the network.

In addition to all this, we want the transactions to have an order, so


every record will also contain a link to the previous record. This
represents the actual blockchain, depicted in Figure 1-4.

Chapter 1 IntroduCtIon to BloCkChaIn

Figure 1-4. A chain of blocks: blockchain

If everybody agreed to use this ledger as a source of truth, there


would be no need to exchange physical money at all. Everybody can
just use the ledger to put in or retrieve money from it.

To understand the technical bits of digital signatures and proof of


work, we will be looking at encryption and hashing, respectively.

Fortunately for us, the programming language that we will be using


has built-in functionalities for encryption and hashing. We don’t have
to dig too deep into how hashing and encryption and decryption
work, but a basic understanding of them will be sufficient.

Observe how we started with a simple definition of a ledger and


gradually built up to a complex system. We will use the same
approach in programming.

1.2 Encryption

We will start with the following definition.

Definition 1-6 Encryption is a method of encoding values such that


only authorized people can view the original content. decryption is a
method of decoding encrypted values.

Chapter 1 IntroduCtIon to BloCkChaIn

Note that in this section we will mostly talk about numbers, but
characters and letters can also be encrypted/decrypted with the same
methods, by using the ASCII2 values for the characters.

Before we talk about encryption, we first have to recall what


functions are, since the encoding/decoding values are achieved with
the usage of them.

1.2.1 Functions

Figure 1-5. A function

Definition 1-7 Functions are mathematical entities that assign


unique outputs to given inputs.

For example, you might have a function that accepts as input a


person and as output returns the person’s age or name. Another
example is the function f ( x) = x + 1. There are many inputs this
function can accept: 1, 2, 3.14. For example, when we input 2, it
gives us an output of 3, since f (2) = 2 + 1 = 3.

2 An ASCII table is a table that assigns a unique number to each


character (such as !, @, a, Z, etc.).

Chapter 1 IntroduCtIon to BloCkChaIn One simple way to think of


functions is in the form of tables. For a function f ( x) accepting a
single argument x, we have a two-column table where the first
column is the input, and the second column is the output.

For a function f ( x, y) accepting two arguments x and y, we have a


three-column table where the first and second columns represent the
input, and the third column is the output. Thus, to display the
function discussed earlier in the form of a table, it would look like
this: x f

( x)

12

23

……
1.2.2 Symmetric-Key Algorithm

We can assume that there exist functions E( x) and D( x) for


encryption and decryption, respectively. We want these functions to
have the following properties:

• E(x) ≠ x, meaning that the encrypted value should

not be the same as the original value

• E(x) ≠ D(x), meaning that the encryption and

decryption functions produce different values

• D(E(x)) = x, meaning that the decryption of an

encrypted value should return the original value

For example, let’s assume there’s some kind of an encryption


scheme, say E("Boro") = 426f726f. We can “safely” communicate the
value 426f726f without actually exposing our original value, and only
those who know the decryption scheme D(x) will be able to see that
D(426f726f) = "Boro".

9
Chapter 1 IntroduCtIon to BloCkChaIn

Another example of encryption scheme is for E(x) to shift every


character in x forward, and for D(x) to shift every character in x
backward.

This scheme is known as the Caesar cipher. To encrypt the text “abc”
we have E("abc") = "bcd", and to decrypt it we have D("bcd") =
"abc".

However, the scheme described makes a symmetric algorithm (Figure


1-6), meaning that we have to share the functions E and D with the
parties involved, and as such, they may be open to attacks.

Figure 1-6. Symmetric-key algorithm

1.2.3 Asymmetric-Key Algorithm

To solve the problems that arise with symmetric-key algorithms, we


will use what is called an asymmetric algorithm or public-key
cryptography (Figure 1-7). In this scheme, we have two kinds of
keys: public and private.

We share the public key with the world and keep the private one to
ourselves.

Figure 1-7. Asymmetric-key algorithm

This algorithm scheme has a neat property where only the private
key can decode a message, and the public key can encode a
message.

10

Chapter 1 IntroduCtIon to BloCkChaIn We have two functions that


should have the same properties as those for the symmetric-key
algorithm.

• E(x, p), which encrypts a message x given a

public key p

• D(x′ , s), which decrypts an encrypted message

x′ given a private (secret) key s

In our example, we will rely on the modulo operation. Recall that a


mod b represents the remainder when a is divided by b. For example,
4 mod 2 = 0 because there is no remainder when dividing 4 by 2;
however, 5 mod 2 = 1.

Here’s one example of a basic encryption algorithm based on addition


and modulo operations:

1. Pick one random number, for example 100. This will represent a
common, publicly available key.

2. Pick another random number in the range (1 , 100), for example


97. This will represent the private key s .

3. The public key p is obtained by subtracting the

common key from the private: 100 − 97 = 3.

4. To encrypt data, add it to the public key and take modulo 100: E(x,
p) = (x + p) mod 100.
5. To decrypt data, we use the same logic but with our private key, so
D(x′ , s) = (x′ + s) mod 100.

For example, suppose we want to encrypt 5. Then E(5, 3) = (5 + 3)


mod 100 = 8. To decrypt 8, we have D(8, 97) = (8 + 97) mod 100 =

105 mod 100 = 5.

This example uses a very simple generation pair of (x + y) mod c.

But, in practice, the pair generation algorithm is much more complex


and harder to break by attackers. After all, the complexity of the
algorithm’s computation is what makes it hard to break it.

11

Chapter 1 IntroduCtIon to BloCkChaIn

We can use a similar algorithm for digital signatures:

• S(x, s), which signs a message x given a private key s (encryption)

• V (x′ , sig, p), which verifies a signed message

x′ , given signature sig and public key p (decryption) As we said


earlier, each record will also include a special number (or a hash).
This hash will be what is produced by S(x, s) (encryption). A hash
can be verified by using the verify function to confirm a record’s
ownership (decryption).

The wallet will contain a pair of public and a private key. These keys
will be used to receive or send money. With the private key, it is
possible to write new blocks (or transactions) to the blockchain,
effectively spending money. With the public key, others can send
currency and verify signatures.

EXERCISE 1-1

Come up with a table of functions such that:

1. the input is a number, and the output is a number 2. the input is a


number, and the output is the name of an employee in a company
given that number

EXERCISE 1-2

Check the three properties for a symmetric-key algorithm to ensure


the Caesar cipher is compatible with them.

12

Chapter 1 IntroduCtIon to BloCkChaIn

EXERCISE 1-3

Come up with an encryption scheme, based on mathematical


substitution.

EXERCISE 1-4

use the asymmetric-key algorithm we defined to sign a message and


verify it.
Hint this is similar to the encryption/decryption example shown
earlier.

1.3 Hashing

Definition 1-8 hashing is a one-way function in that it encodes text


without a way to retrieve the original value.

Hashing is simpler than the previously described encryption schemes.


One example of a hashing function is to return the length of
characters as in H

("abc") = 3, but also H ("bcd") = 3. This means we don’t have a way


to retrieve the original value just by using the return value 3.

As we mentioned earlier, the reason to use such a technique is that it


has some interesting properties, such as providing us with the proof
of work.

Definition 1-9 Mining is the process of validating transactions.

For this effort, successful miners obtain money as a reward.

13

Chapter 1 IntroduCtIon to BloCkChaIn

Hashcash is one kind of a proof-of-work system.3 We will use it to


implement mining. We will see how this algorithm works in detail in
the later chapters where we will implement it.

Hashing functions have another useful property that allows


connecting two or more distinct blocks by having the information
about the current block’s hash (current hash) and previous block’s
hash (previous hash) in each block. For example, block-1 may have a
hash such as 123456, and block-2 may have a hash such as 345678.
Now, block-2’s previous-hash will be block-1’s current hash, that is,
123456. Here, we linked these two blocks, thus effectively creating a
linked list of blocks containing ledgers with transactions. Figure 1-4
depicts this linking.

The hash of the block is based on the block’s data itself, so to verify a
hash we can just hash the block’s data and compare it to current
hash.

Two or more blocks (or transactions) that are connected form a


blockchain. The validity of the blockchain will depend on the validity
of each transaction.

EXERCISE 1-5

Come up with your own hashing function.

EXERCISE 1-6

In which way can the linked list depicted in Figure 1-4 be traversed?
What are the implications of this property?

3 Hashcash was initially targeted for limiting email spam and other
attacks.

However, recently it’s also become known for its usage in blockchains
as part of the mining process. Hashcash was proposed in 1997 by
Adam Backa.

14

Chapter 1 IntroduCtIon to BloCkChaIn


1.4 Smart Contracts

Definition 1-10 a

smart contract is a self-executing contract

with the conditions of an agreement between a buyer and a seller


being directly written into lines of code.

A blockchain is programmable if the transactions themselves can be


programmed by users. For example, users (not necessarily
programmers) can write a script to add additional requirements that
must be satisfied before sending money. It could look something like
this: 1 if (user has more than 10 money)

2 then approve transaction

3 else reject transaction

Smart contracts are implemented as a computation that takes place


on the blockchain.

1.5 Bitcoin

Bitcoin was the world’s first implementation of a blockchain. In


November 2008, a link to a paper authored by Satoshi Nakamoto
titled “Bitcoin: A Peer-to-Peer Electronic Cash System” was published
on a cryptography mailing list. Bitcoin’s white paper consists of nine
pages; however, it is a mostly theoretical explanation of the design
and as such may be a bit overwhelming to newcomers.

The Bitcoin software is open source code and was released in


January 2009 on SourceForge. The design of a Bitcoin includes a
decentralized network (peer-to-peer network), block (mining),
blockchain, transactions, and wallets, each of which we will look at in
detail in this book.

15
Chapter 1 IntroduCtIon to BloCkChaIn Although there are many
blockchain models and each one of them differs in implementation
details, the blockchain we will be building upon in this book will look
pretty similar to Bitcoin, with some parts simplified.

1.6 Example Workflows

We will list a few important workflows that our system will use,
among others.

Mining a block creates a new block, using Hashcash to calculate the


current hash of the block. It also contains the previous hash that is a
link to the previous block in the blockchain.

Checking a wallet balance for person A will first filter all blocks in the
blockchain (sender = A or receiver = A) and then sum them to
calculate the balance. The more our blockchain grows, the longer this
operation will take. For that purpose, we will use unspent transaction
outputs or the UTXO model. This model is a list of transactions
containing information about the owner and the amount of money.
Thus, every transaction will consume elements from this list.

Adding a block to a blockchain consists of sending money from A to


B. One prerequisite is that A has enough money; we check this using
the wallet balance workflow. We proceed by creating a transaction
(sender =

A, receiver = B) and signing it. Then we mine a block using this


transaction and update the UTXO with the rewards.

1.7 Summary

The point of this chapter is to get a vague idea of how the system
that we will implement looks. Things will become much clearer in the
next chapter where we will be explicit about the definitions of every
entity.
16

Chapter 1 IntroduCtIon to BloCkChaIn Here’s what we learned in this


chapter, briefly:

• The core entity of the system is a block.

• A block contains (among other data) transactions.

• We have a ledger that is an ordered list of all valid blocks


(blockchain.)

• Every peer involved with the ledger has a wallet.

• Every record in the ledger is signed by the owner and can be


verified by the public (digital signatures).

• The ledger is in a decentralized location; that is, everybody has a


copy of it.

• Trust is based upon proof of work (mining).

17
CHAPTER 2

Model: Blockchain

Core

“Block” by Filip Rizov

© Spiro Buzharovski 2022


19

S. Buzharovski, Introducing Blockchain with Java,

https://doi.org/10.1007/978-1-4842-7927-4_2

Chapter 2 Model: BloCkChain Core

Now that we have explained in theory what a blockchain is and how


it is useful, the next obvious step is to start implementing it in Java.
In this chapter, we will start by creating the model classes that
represent the most elementary building blocks for our application.
You can either look at the code snippets provided or download the
complete repository from https://github.com/

5pir3x/e- coin. The exercises included will offer insight and give you
ideas for you to modify my code to create alternative
implementations of various aspects of the application. I urge you to
try to complete as many of them as possible; my hope is that at the
end you will have not only a greater and deeper understanding of
blockchain technology but also with a great project for your portfolio
that’s an alternative to my implementation instead of a mere copy. I
have chosen to create a folder named Model inside my
src.com.company folder structure in my repository and keep my
model classes there. It is recommended that you choose the same
folder structure for your project to avoid any pathing or import
problems.

2.1 Block.java

We will start first by listing the imports in the following code snippet:
1 package com.company.Model;

3 import sun.security.provider.DSAPublicKeyImpl; 4

5 import java.io.Serializable;
6 import java.security.InvalidKeyException;

7 import java.security.Signature;

8 import java.security.SignatureException;

9 import java.util.ArrayList;

10 import java.util.Arrays;

11 import java.util.LinkedList;

12

20

Chapter 2 Model: BloCkChain Core

Next we move on to our class declaration and fields, as shown in our


next code snippet:

13 public class Block implements Serializable {

14

15 private byte[] prevHash;

16 private byte[] currHash;

17 private String timeStamp;

18 private byte[] minedBy;

19 private Integer ledgerId = 1;

20 private Integer miningPoints = 0;

21 private Double luck = 0.0;


22

23 private ArrayList< Transaction> transactionLedger = new


ArrayList<>();

The first thing we recognize on line 13 is that this class implements


the interface Serializable. Since all the blocks for our blockchain will
be created using this class, we need them to be serializable so that
we can share our blockchain through our network.

The field prevHash will contain the signature or, in other words, the
encrypted data from the previous block. The currHash will contain the
signature or, in other words, the encrypted data from this block,
which will be encrypted with the private key of the miner that will get
to mine this block. The timeStamp obviously will contain a timestamp
of when this block was mined/finalized. The field minedBy will contain
the public key, which also doubles as the public address of the miner
that managed to mine this block. In the process of blockchain
verification, this public address/public key will be used to verify that
the currHash/signature of this block is the same as the hash of the
data presented by this block and secondary that this block was
indeed mined by this particular miner.

21

Chapter 2 Model: BloCkChain Core

We will touch on this topic a bit later in this section when we explain
the isVerified method of this class. Next is our ledgerId field. Since
we intend to implement a database with separate Block and
Transaction tables, this field will help us retrieve the correct
corresponding ledger for this block. You can also look at this field as
the block number. Our next fields, miningPoints and luck, will be used
to form the network consensus in regard to choosing this block’s
miner.

We will get into the details of how these fields are used in Chapter 6.
The field transactionLedger is simply an arraylist of all the
transactions contained in this block. We will explain the Transaction
class in the section “Transaction.java.”

In the following snippet, we can see the three constructors starting


on line 26, line 38, and line 45:

25 //This constructor is used when we retrieve it from the db

26 public Block(byte[] prevHash, byte[] currHash, String timeStamp,


byte[] minedBy,Integer ledgerId, 27 Integer miningPoints, Double
luck,

ArrayList< Transaction> transactionLedger) {

28 this.prevHash = prevHash;

29 this.currHash = currHash;

30 this.timeStamp = timeStamp;

31 this.minedBy = minedBy;

32 this.ledgerId = ledgerId;

33 this.transactionLedger = transactionLedger; 34 this.miningPoints


= miningPoints;

35 this.luck = luck;

36 }

37 //This constructor is used when we initiate it after retrieve.

38 public Block(LinkedList< Block> currentBlockChain) {

22

Chapter 2 Model: BloCkChain Core


39 Block lastBlock = currentBlockChain.getLast(); 40 prevHash =
lastBlock.getCurrHash(); 41 ledgerId = lastBlock.getLedgerId() + 1;
42 luck = Math.random() * 1000000;

43 }

44 //This constructor is used only for creating the first block in the
blockchain.

45 public Block() {

46 prevHash = new byte[]{0}; 47 }

48

The first constructor is used when we retrieve our blockchain from


the database. Here we retrieve all the blocks completely finalized,
and this constructor helps us instantiate the block with all of the
fields properly set up. The second constructor is used while the
application is running and is used to create a completely new block
(in other words, the head of the blockchain) for us to work on. We
will go over the details of how this is achieved in Chapter 6. Our third
constructor on line 45 will be used only once by our init() method to
create our first block.

Our next snippet showcases the isVerified method:

48

49 public Boolean isVerified(Signature signing) 50 throws


InvalidKeyException, SignatureException {

51 signing.initVerify(new DSAPublicKeyImpl(this.minedBy)); 52
signing.update(this.toString().getBytes()); 53 return
signing.verify(this.currHash); 54 }

55
23

Chapter 2 Model: BloCkChain Core

We accept an object from the Signature class as a parameter. The


Signature class is actually a class from the java security package java.

security.Signature. It is a helper singleton class that allows us to


encrypt/decrypt data using different algorithms. On line 51 we initiate
the signing parameter by using the public key from the minedBy field
of this class. We will use this key to verify the data in this class
against the signature stored in the currHash. On line 52 we insert the
data that we want to verify, which in our case is the contents of the
toString method.

On line 53 we return the Boolean result after verifying the data


contained in this class against its currHash.

What’s left, as shown in our next snippet, are the equals and hash
methods, the generic getters and setters, and the toString() method,
which concludes our Block.java class:

55

56 @Override

57 public boolean equals(Object o) {

58 if (this == o) return true;

59 if (!(o instanceof Block)) return false; 60 Block block =


(Block) o;

61 return Arrays.equals(getPrevHash(), block.getPrevHash());

62 }

63
64 @Override

65 public int hashCode() {

66 return Arrays.hashCode(getPrevHash()); 67 }

68

69 public byte[] getPrevHash() { return prevHash; }

70 public byte[] getCurrHash() { return currHash; }

71

24

Chapter 2 Model: BloCkChain Core

72 public void setPrevHash(byte[] prevHash) { this.prevHash =

prevHash; }

73 public void setCurrHash(byte[] currHash) { this.currHash =

currHash; }

74

75 public ArrayList< Transaction> getTransactionLedger() {

return transactionLedger; }

76 public void setTransactionLedger(

ArrayList< Transaction> transactionLedger) {

77 this.transactionLedger = transactionLedger; 78 }

79
80 public String getTimeStamp() { return timeStamp; }

81 public void setMinedBy(byte[] minedBy) {

this.minedBy = minedBy; }

82

83 public void setTimeStamp(String timeStamp) {

this.timeStamp = timeStamp; }

84

85 public byte[] getMinedBy() { return minedBy; }

86

87 public Integer getMiningPoints() { return miningPoints; }

88 public void setMiningPoints(Integer miningPoints) {

this.miningPoints = miningPoints; }

89 public Double getLuck() { return luck; }

90 public void setLuck(Double luck) { this.luck = luck; }

91

92 public Integer getLedgerId() { return ledgerId; }

93 public void setLedgerId(Integer ledgerId) {

this.ledgerId = ledgerId; }

94

25
Chapter 2 Model: BloCkChain Core

95 @Override

96 public String toString() {

97 return "Block{" +

98 "prevHash=" + Arrays.toString(prevHash) +

99 ", timeStamp='" + timeStamp + '\'' +

100 ", minedBy=" + Arrays.toString(minedBy) +

101 ", ledgerId=" + ledgerId +

102 ", miningPoints=" + miningPoints +

103 ", luck=" + luck +

104 '}';

105 }

106}

107

The first thing to note here is that the equals method compares the
previous hash of the block class. We’ll use this later in Chapter 6
when we explain the consensus algorithm further. The other thing of
note is the fields contained in the toString method. We include
everything that goes into verifying the block against the current hash.

Important!
• remember that a wallet’s public key is also the wallet’s public
address/account number.

• the current hash/signature of the block is just the encrypted version


of the data contained in the block.

• the miner’s private key is used to encrypt the block’s data, which
creates the signature.

26

Chapter 2 Model: BloCkChain Core

• the miner’s public key is used for other peers to verify the block by
comparing the signature’s hash against the hash of the block’s data.

• note how we use the toString() method throughout this class to


prep our data conveniently for comparison.

• note how all of the essential fields that make certain the block is
unique are included in the toString() method.

2.2 Transaction.java

We briefly mentioned that we keep an array list of transactions in our


Block class in the previous section, and now it’s time to explain in
detail what our Transaction.java class contains. First we’ll start with
the imports found in the following code snippet:

1 package com.company.Model;

3 import sun.security.provider.DSAPublicKeyImpl; 4

5 import java.io.Serializable;

6 import java.security.InvalidKeyException;
7 import java.security.Signature;

8 import java.security.SignatureException;

9 import java.time.LocalDateTime;

10 import java.util.Arrays;

11 import java.util.Base64;

12

27

Chapter 2 Model: BloCkChain Core

Next let’s go over the class declaration and its fields, as shown in the
next code snippet:

13 public class Transaction implements Serializable {

14

15 private byte[] from;

16 private String fromFX;

17 private byte[] to;

18 private String toFX;

19 private Integer value;

20 private String timestamp;

21 private byte[] signature;

22 private String signatureFX;


23 private Integer ledgerId;

24

Since this class also creates objects from which we are building our
blockchain, it will implement the interface serializable so that it’s
shareable through the network.

The fields from and to will contain the public keys/addresses of the
account that sends and the account that receives the coins,
respectively.

The value is the amount of coins that will be sent, and timeStamp is
the time at which the transaction has occurred. Signature will contain
the encrypted information of all the fields, and it will be used to verify
the validity of the transaction (it will be used the same way the field
currHash was used in the previous class).The ledgerId serves the
same purpose as in the previous class. The fields with the FX suffix
are simple duplicates formatted to String instead of byte[]. We do
this so that we can easily display them on our front end.

In this class we also have two constructors; the first one is used
when we retrieve a transaction from the database, and the second
one is used when we want to create a new transaction within our
application. Let’s observe them in the following code snippet:

28

Chapter 2 Model: BloCkChain Core

26 //Constructor for loading with existing signature 27 public


Transaction(byte[] from, byte[] to, Integer value, byte[] signature,
Integer ledgerId,

28 String timeStamp) {

29 Base64.Encoder encoder = Base64.getEncoder(); 30 this.from =


from;
31 this.fromFX = encoder.encodeToString(from); 32 this.to = to;

33 this.toFX = encoder.encodeToString(to); 34 this.value = value;

35 this.signature = signature;

36 this.signatureFX = encoder.encodeToString(signature); 37
this.ledgerId = ledgerId;

38 this.timestamp = timeStamp;

39 }

40 //Constructor for creating a new transaction and signing it.

41 public Transaction (Wallet fromWallet, byte[] toAddress, Integer


value, Integer ledgerId,

42 Signature signing) throws InvalidKeyException,


SignatureException {

43 Base64.Encoder encoder = Base64.getEncoder(); 44 this.from =


fromWallet.getPublicKey().getEncoded(); 45 this.fromFX =
encoder.encodeToString(

fromWallet.getPublicKey().getEncoded()); 46 this.to = toAddress;

47 this.toFX = encoder.encodeToString(toAddress); 48 this.value =


value;

49 this.ledgerId = ledgerId;

50 this.timestamp = LocalDateTime.now().toString(); 51
signing.initSign(fromWallet.getPrivateKey()); 29
Chapter 2 Model: BloCkChain Core

52 String sr = this.toString();

53 signing.update(sr.getBytes()); 54 this.signature = signing.sign();


55 this.signatureFX = encoder.encodeToString(this

.signature);

56 }

57

The first constructor simply sets the class fields according to the
retrieved data from the database and uses the Base64.Encoder class
to convert the byte[] fields safely into String.

The second constructor is a bit more complex, so we will explain it in


more detail piece by piece. First let’s look at the constructor
parameters that are different: Wallet fromWallet and Signature
signing. We will explain the Wallet class in more detail in the next
section, for now we should just note that the fromWallet parameter
contains the public and private keys of the sender/maker of the
transaction. We use the same Signature class as in our Block
isVerified method mentioned in the previous section.

Next let’s explain the body of the constructor so we understand how


encrypting data works in our case. The signature creation phase
shown in Figure 2-1 offers an overview of what we are trying to
accomplish.
Figure 2-1. Signature creation

30

Chapter 2 Model: BloCkChain Core

To achieve this, first we set up our data by initiating our class fields
from the parameters and add a timestamp as shown on lines 44 to
50. Now once we have our data that we would like to encrypt, we set
our private key to the signing object with the statement on line 51.
This tells the signing object, when encrypting, to use the private key
we provided. On line 52

we are putting all the data we want to encrypt in a single String


object by using the toString() method. On line 53 we are feeding all
the data we want to encrypt to the signing object, and on line 54 we
are actually encrypting the data and assigning it to our signature
field.

Next is our method for the verification of transactions, as shown in


the following snippet:

58 public Boolean isVerified(Signature signing) 59 throws


InvalidKeyException, SignatureException {

60 signing.initVerify(new DSAPublicKeyImpl(this.

getFrom()));

61 signing.update(this.toString().getBytes()); 62 return
signing.verify(this.signature); 63 }

64

This method will be used by the other peers to verify that each
transaction is valid. Before explaining the code, let’s look at Figure 2-
2 and see what our method tries to accomplish.
31

Chapter 2 Model: BloCkChain Core

Figure 2-2. Verification phase

The workflow of the schematic is quite simple; we need to compare


the hash of the signature and the hash of the data contained in our
class using the public key.

Now let’s look back at our isVerified method and explain how the
workflow from the schematic is achieved. As parameters we are
getting the Transaction object that we want to verify and the
Signature helper class object, which pre-initialized to use SHA256
with DSA algorithm the same way as before. On line 60 we are
setting the public key with which we would like to decrypt our
signature. The new DSAPublicKeyImpl(byte[]
encoded) is just a wrapper from the sun.security.provider package
that will help convert our public key information from byte[] to
PublicKey object. On line 61 we set the transaction data that we want
to verify against the signature. Finally on line
Blockchaintransaction.java 62 we provide the signature, the process
of comparison/verification gets executed and a result is returned
automatically for us.

32

Chapter 2 Model: BloCkChain Core

We finish up the rest of the class with generic getters, setters, and
our toString, equals, and hash methods, as shown in the following
snippet: 65 @Override

66 public String toString() {

67 return "Transaction{" +

68 "from=" + Arrays.toString(from) +

69 ", to=" + Arrays.toString(to) +

70 ", value=" + value +

71 ", timeStamp= " + timestamp +

72 ", ledgerId=" + ledgerId +

73 '}';

74 }

75

76 public byte[] getFrom() { return from; }


Exploring the Variety of Random
Documents with Different Content
“And I smiled to think God’s greatness flowed around our
incompleteness—
Round our restlessness, His rest.”

Compare “By the Fireside,” especially stanza 39.


EVELYN HOPE.
I.

Beautiful Evelyn Hope is dead!


Sit and watch by her side an hour.
That is her book-shelf, this her bed;
She plucked that piece of geranium-flower,
Beginning to die too, in the glass;
Little has yet been changed, I think:
The shutters are shut, no light may pass
Save two long rays through the hinge’s chink.

II.

Sixteen years old when she died!


Perhaps she had scarcely heard my name;
It was not her time to love; beside,
Her life had many a hope and aim,
Duties enough and little cares,
And now was quiet, now astir,
Till God’s hand beckoned unawares,—
And the sweet white brow is all of her.

III.

Is it too late then, Evelyn Hope?


What, your soul was pure and true,
The good stars met in your horoscope,
Made you of spirit, fire and dew—
And, just because I was thrice as old,
And our paths in the world diverged so wide.
Each was nought to each, must I be told?
We were fellow mortals, nought beside?

IV.

No, indeed! for God above


Is great to grant, as mighty to make,
And creates the love to reward the love:
I claim you still, for my own love’s sake!
Delayed it may be for more lives yet,
Through worlds I shall traverse, not a few:
Much is to learn, much to forget
Ere the time be come for taking you.

V.

But the time will come, at last it will,


When, Evelyn Hope, what meant (I shall say)
In the lower earth, in the years long still,
That body and soul so pure and gay?
Why your hair was amber, I shall divine,
And your mouth of your own geranium’s red—
And what you would do with me, in fine,
In the new life come in the old one’s stead.

VI.

I have lived (I shall say) so much since then,


Given up myself so many times,
Gained me the gains of various men,
Ransacked the ages, spoiled the climes;
Yet one thing, one, in my soul’s full scope,
Either I missed or itself missed me:
And I want and find you, Evelyn Hope!
What is the issue? let us see!

VII.

I loved you, Evelyn, all the while!


My heart seemed full as it could hold;
There was place and to spare for the frank young smile
And the red young mouth, and the hair’s young gold.
So hush,—I will give you this leaf to keep:
See, I shut it inside the sweet cold hand!
There, that is our secret: go to sleep!
You will wake, and remember, and understand.

This poem, so exquisite in finish, well-nigh perfect in form, is one of


the few works of our author, almost universally known and admired.
It is doubtful, however, if all its admirers look beneath the form and
finish, or understand much more of it than they do of other poems,
the crabbed style of which repels admiration as strongly as this
attracts it. The tender pathos of the “geranium leaf” in the first and
last stanzas, touches a chord in every heart; but the thought of the
piece is something far deeper and stronger, namely this, that true
love is immortal, and that, therefore, however much it may fail of its
object here, or even (if possible) in lives that follow this, it cannot
fail for ever, it must find its object and be satisfied. It is a poem, not
of the pathos of death, but of the promise of Life!
PROSPICE.
Fear death?—to feel the fog in my throat,
The mist in my face,
When the snows begin, and the blasts denote
I am nearing the place,
The power of the night, the press of the storm,
The post of the foe;
Where he stands the Arch Fear in a visible form,
Yet the strong man must go:
For the journey is done and the summit attained,
And the barriers fall,
Though a battle’s to fight ere the guerdon be gained,
The reward of it all.
I was ever a fighter, so—one fight more,
The best and the last!
I would hate that death bandaged my eyes, and forebore,
And bade me creep past.
No! let me taste the whole of it, fare like my peers
The heroes of old,
Bear the brunt, in a minute pay glad life’s arrears
Of pain, darkness and cold.
For sudden the worst turns the best to the brave,
The black minute’s at end,
And the elements’ rage, the fiend-voices that rave,
Shall dwindle, shall blend,
Shall change, shall become first a peace out of pain,
Then a light, then thy breast,
O thou soul of my soul! I shall clasp thee again,
And with God be the rest!
GOOD, TO FORGIVE.
I.

Good, to forgive;
Best, to forget!
Living, we fret;
Dying, we live.
Fretless and free,
Soul, clap thy pinion!
Earth have dominion,
Body, o’er thee!

II.

Wander at will,
Day after day,—
Wander away,
Wandering still—
Soul that canst soar!
Body may slumber:
Body shall cumber
Soul-flight no more

III.

Waft of soul’s wing!


What lies above?
Sunshine and Love,
Sky-blue and Spring!
Body hides—where?
Ferns of all feather,
Mosses and heather,
Yours be the care!

This is the proem to “La Saisiaz,” one of the most remarkable of the
poet’s works, in which the doctrine of immortality is argued with a
profundity of thought that has perhaps never been surpassed, even
in language freed from the fetters of verse. It also appears as No.
III. of “Pisgah Sights” in the second English series of selections. Both
of these connections suggest the key-note.
Observe the progress in the thought. In the first stanza the soul is
“fretless and free”; in the second it moves onward and upward; in
the third it has reached the region of “Sunshine and Love, Sky-blue
and Spring!” Similarly as to the body—in the first stanza there is the
apparent victory of the grave, “dust to dust”; in the next comes the
thought that, after all, the body may only be slumbering; in the last,
there is the beautiful suggestion that it is only hiding where it is
tenderly cared for, till
“——with the morn those angel faces smile
Which we have loved long since, and lost awhile.”
TOUCH HIM NE’ER SO LIGHTLY.

“Touch him ne’er so lightly, into song he broke:


Soil so quick-receptive,—not one feather-seed,
Not one flower-dust fell but straight its fall awoke
Vitalizing Virtue: song would song succeed
Sudden as spontaneous—prove a poet-soul!”

Indeed?
Rock’s the song-soil rather, surface hard and bare:
Sun and dew their mildness, storm and frost their rage
Vainly both expend,—few flowers awaken there:
Quiet in its cleft broods—what the after age
Knows and names a pine, a nation’s heritage.

These lines appeared first as the Epilogue to the second series of


Dramatic Idyls, published in 1880. In October of the same year, the
poet wrote, in the Album of a young American lady, a sequel to
them, which appeared (in fac-simile) in the Century Magazine of
November, 1882. They are given here, with the kind consent of the
publishers of that magazine:—
Thus I wrote in London, musing on my betters,
Poets dead and gone: and lo, the critics cried
“Out on such a boast!”—as if I dreamed that fetters
Binding Dante, bind up—me! as if true pride
Were not also humble!
So I smiled and sighed
As I ope’d your book in Venice this bright morning,
Sweet new friend of mine! and felt tho’ clay or sand—
Whatsoe’er my soil be,—break—for praise or scorning—
Out in grateful fancies—weeds, but weeds expand
Almost into flowers, held by such a kindly hand!
POPULARITY.
I.

Stand still, true poet that you are!


I know you; let me try and draw you.
Some night you’ll fail us: when afar
You rise, remember one man saw you,
Knew you, and named a star!

II.

My star, God’s glow-worm! Why extend


That loving hand of His which leads you,
Yet locks you safe from end to end
Of this dark world, unless He needs you,
Just saves your light to spend?

III.

His clenched hand shall unclose at last,


I know, and let out all the beauty:
My poet holds the future fast,
Accepts the coming ages’ duty,
Their present for this past.

IV.

That day, the earth’s feast-master’s brow


Shall clear, to God the chalice raising;
“Others give best at first, but Thou
“Forever set’st our table praising,
“Keep’st the good wine till now!”

V.

Meantime, I’ll draw you as you stand,


With few or none to watch and wonder:
I’ll say—a fisher, on the sand
By Tyre the old with ocean plunder
By Tyre the old, with ocean-plunder,
A netful, brought to land.

VI.

Who has not heard how Tyrian shells


Enclosed the blue, that dye of dyes
Whereof one drop worked miracles,
And coloured like Astarte’s eyes
Raw silk the merchant sells?

VII.

And each bystander of them all


Could criticize, and quote tradition
How depths of blue sublimed some pall
—To get which, pricked a king’s ambition;
Worth sceptre, crown and ball.

VIII.

Yet there’s the dye, in that rough mesh,


The sea has only just o’er-whispered!
Live whelks, each lip’s beard dripping fresh,
As if they still the water’s lisp heard
Through foam the rock-weeds thresh.

IX.

Enough to furnish Solomon


Such hangings for his cedar-house,
That, when gold-robed he took the throne
In that abyss of blue, the Spouse
Might swear his presence shone.

X.

Most like the centre-spike of gold


Which burns deep in the blue-bell’s womb
What time, with ardours manifold,
The bee goes singing to her groom,
Drunken and overbold.

XI.

Mere conchs! not fit for warp or woof!


Till cunning come to pound and squeeze
And clarify,—refine to proof
The liquor filtered by degrees,
While the world stands aloof.

XII.

And there’s the extract, flasked and fine,


And priced and saleable at last!
And Hobbs, Nobbs, Stokes and Nokes combine
To paint the future from the past,
Put blue into their line.

XIII.

Hobbs hints blue,—straight he turtle eats:


Nobbs prints blue,—claret crowns his cup:
Nokes outdares Stokes in azure feats,—
Both gorge. Who fished the murex up?
What porridge had John Keats?

The true poet is he who discovers and discloses, for man’s


recognition and enjoyment, the hidden beauties which abound
everywhere in the great kingdom of God. These beauties may be
unrecognised at first, so that the poet is not known as a poet,
except to such as the speaker here is supposed to be (“I know
you”). He recognises in him a star. How is it, then, that his light is
hidden? The hand of God, who looks down on him from far above
(“God’s glow-worm”) as I look up to him from far below (“my star”),
has closed around him to keep him and his light safe till the time
shall come for discovery (Stanza 3) and for recognition (4). The
drawing, or simile follows, of a Tyrian fisherman (5), who brings
from the great sea the common-looking little whelk, from which, by
a secret process, is obtained that wonderful dye which out-dazzles
art, and almost equals Nature’s most exquisite tints (6-10). While the
process is going on, the world stands aloof (11); but as soon as the
extract is “priced and saleable,” the commonest people (12) can
recognise it and make it pay (13); while the man who fished it up
remains poor and unknown to fame.
The application is made with characteristic brevity, oddity, and
antithetic power: Nokes, Stokes, & Co., gorging turtle; John Keats
wanting porridge!
In connection with “Popularity” should be studied “The Two Poets of
Croisic,” far too long to be inserted here. An interesting comparison,
also, may be made with a little poem of Tennyson’s called “The
Flower,” beginning—
“Once in a golden hour
I cast to earth a seed,
Up there came a flower,
The people said, a weed.”
THE GUARDIAN-ANGEL.

A PICTURE AT FANO.
I.

Dear and great Angel, wouldst thou only leave


That child, when thou hast done with him, for me!
Let me sit all the day here, that when eve
Shall find performed thy special ministry,
And time come for departure, thou, suspending
Thy flight, may’st see another child for tending,
Another still, to quiet and retrieve.

II.

Then I shall feel thee step one step, no more,


From where thou standest now, to where I gaze.
—And suddenly my head is covered o’er
With those wings, white above the child who prays
Now on that tomb—and I shall feel thee guarding
Me, out of all the world; for me, discarding
Yon heaven thy home, that waits and opes its door.

III.

I would not look up thither past thy head


Because the door opes, like that child, I know,
For I should have thy gracious face instead,
Thou bird of God! And wilt thou bend me low
Like him, and lay, like his, my hands together,
And lift them up to pray, and gently tether
Me, as thy lamb there, with thy garment’s spread?

IV.

If this was ever granted, I would rest


My head beneath thine, while thy healing hands
Close-covered both my eyes beside thy breast,
Pressing the brain which too much thought expands,
Back to its proper size again, and smoothing
Distortion down till every nerve had soothing,
And all lay quiet, happy and suppressed.

V.

How soon all worldly wrong would be repaired!


I think how I should view the earth and skies
And sea, when once again my brow was bared
After thy healing, with such different eyes.
O world, as God has made it! All is beauty:
And knowing this, is love, and love is duty.
What further may be sought for or declared?

VI.

Guercino drew this angel I saw teach


(Alfred, dear friend!)—that little child to pray,
Holding the little hands up, each to each
Pressed gently,—with his own head turned away
Over the earth where so much lay before him
Of work to do, though heaven was opening o’er him,
And he was left at Fano by the beach.

VII.

We were at Fano, and three times we went


To sit and see him in his chapel there,
And drink his beauty to our soul’s content
—My angel with me too: and since I care
For dear Guercino’s fame (to which in power
And glory comes this picture for a dower,
Fraught with a pathos so magnificent),

VIII.

And since he did not work thus earnestly


At all times, and has else endured some wrong—
I took one thought his picture struck from me
I took one thought his picture struck from me,
And spread it out, translating it to song.
My love is here. Where are you, dear old friend?
How rolls the Wairoa at your world’s far end?
This is Ancona, yonder is the sea.

“The Guardian Angel” is given as a slight specimen of an important


class, dealing with painting and painters. In the lovely poem, “One
Word More,” Browning disclaims all ability to paint; but no one could
have a more exquisite appreciation of the art.
Has the tender pathos of these verses ever been surpassed? The
calm of heaven is in this thought spread out—translated into song.
Let it be read in connection with Spenser’s exquisite lines, beginning
“And is there care in heaven?”
“Alfred, dear friend,” is Mr. Alfred Domett, who was then Prime
Minister of New Zealand, at which far end of the world the Wairoa
rolls to the sea.
DEAF AND DUMB.

A GROUP BY WOOLNER.

Only the prism’s obstruction shows aright


The secret of a sunbeam, breaks its light
Into the jewelled bow from blankest white;
So may a glory from defect arise:
Only by Deafness may the vexed love wreak
Its insuppressive sense on brow and cheek,
Only by Dumbness adequately speak
As favoured mouth could never, through the eyes.

This is a “gem of purest ray.” In order to understand it fully, it is


necessary to know that the “group by Woolner” is of two deaf and
dumb children—the one as if speaking, the other in the attitude of
listening. The speech denied passage through the lips, breaks out in
rarer beauty from the eyes; and for the hearing denied entrance by
the ears, there is, instead, a subtle responsiveness of brow and
cheek to the spirit utterance from the soul of the other; so that love,
though “vexed,” is not suppressed.
The exquisite beauty of the illustration of “the prism’s obstruction,”
and the tender pathos of the thought, will be manifest to every
reader.
ABT VOGLER.

(AFTER HE HAS BEEN EXTEMPORIZING UPON THE MUSICAL


INSTRUMENT OF HIS INVENTION.)
I.

Would that the structure brave, the manifold music I build,


Bidding my organ obey, calling its keys to their work,
Claiming each slave of the sound, at a touch, as when Solomon
willed
Armies of angels that soar, legions of demons that lurk,
Man, brute, reptile, fly,—alien of end and of aim,
Adverse, each from the other heaven-high, hell-deep removed,—
Should rush into sight at once as he named the ineffable Name,
And pile him a palace straight, to pleasure the princess he loved!

II.

Would it might tarry like his, the beautiful building of mine,


This which my keys in a crowd pressed and importuned to raise!
Ah, one and all, how they helped, would dispart now and now
combine,
Zealous to hasten the work, heighten their master his praise!
And one would bury his brow with a blind plunge down to hell,
Burrow awhile and build, broad on the roots of things,
Then up again swim into sight, having based me my palace well,
Founded it, fearless of flame, flat on the nether springs.

III.

And another would mount and march, like the excellent minion he
was,
Ay, another and yet another, one crowd but with many a crest,
Raising my rampired walls of gold as transparent as glass,
Eager to do and die, yield each his place to the rest:
For higher still and higher (as a runner tips with fire,
When a great illumination surprises a festal night—
Outlining round and round Rome’s dome from space to spire)
Up, the pinnacled glory reached, and the pride of my soul was in
sight.
IV.

In sight? Not half! for it seemed, it was certain, to match man’s


birth,
Nature in turn conceived, obeying an impulse as I;
And the emulous heaven yearned down, made effort to reach the
earth,
As the earth had done her best, in my passion, to scale the sky:
Novel splendours burst forth, grew familiar and dwelt with mine,
Not a point nor peak but found, but fixed its wandering star;
Meteor-moons, balls of blaze: and they did not pale nor pine,
For earth had attained to heaven, there was no more near nor far.

V.

Nay more; for there wanted not who walked in the glare and glow,
Presences plain in the place; or, fresh from the Protoplast,
Furnished for ages to come, when a kindlier wind should blow,
Lured now to begin and live, in a house to their liking at last;
Or else the wonderful Dead who have passed through the body and
gone,
But were back once more to breathe in an old world worth their
new:
What never had been, was now; what was, as it shall be anon;
And what is,—shall I say, matched both? for I was made perfect
too.

VI.

All through my keys that gave their sounds to a wish of my soul,


All through my soul that praised as its wish flowed visibly forth,
All through music and me! For think, had I painted the whole,
Why, there it had stood, to see, nor the process so wonder-worth.
Had I written the same, made verse—still, effect proceeds from
cause,
Ye know why the forms are fair, ye hear how the tale is told;
It is all triumphant art, but art in obedience to laws
t s a t u p a t a t, but a t obed e ce to a s
Painter and poet are proud, in the artist-list enrolled:—

VII.

But here is the finger of God, a flash of the will that can,
Existent behind all laws: that made them, and, lo, they are!
And I know not if, save in this, such gift be allowed to man,
That out of three sounds he frame, not a fourth sound, but a star.
Consider it well: each tone of our scale in itself is nought;
It is everywhere in the world—loud, soft, and all is said:
Give it to me to use! I mix it with two in my thought,
And, there! Ye have heard and seen: consider and bow the head!

VIII.

Well, it is gone at last, the palace of music I reared;


Gone! and the good tears start, the praises that come too slow;
For one is assured at first, one scarce can say that he feared,
That he even gave it a thought, the gone thing was to go.
Never to be again! But many more of the kind
As good, nay, better perchance: is this your comfort to me?
To me, who must be saved because I cling with my mind
To the same, same self, same love, same God: ay, what was, shall
be.

IX.

Therefore to whom turn I but to Thee, the ineffable Name?


Builder and maker, thou, of houses not made with hands!
What, have fear of change from thee who art ever the same?
Doubt that thy power can fill the heart that thy power expands?
There shall never be one lost good! What was, shall live as before;
The evil is null, is nought, is silence implying sound;
What was good, shall be good, with, for evil, so much good more;
On the earth the broken arcs; in the heaven, a perfect round.

X.
All we have willed or hoped or dreamed of good, shall exist;
Not its semblance, but itself; no beauty, nor good, nor power
Whose voice has gone forth, but each survives for the melodist,
When eternity affirms the conception of an hour.
The high that proved too high, the heroic for earth too hard,
The passion that left the ground to lose itself in the sky,
Are music sent up to God by the lover and the bard;
Enough that he heard it once: we shall hear it by-and-by.

XI.

And what is our failure here but a triumph’s evidence


For the fulness of the days? Have we withered or agonized?
Why else was the pause prolonged but that singing might issue
thence?
Why rushed the discords in, but that harmony should be prized?
Sorrow is hard to bear, and doubt is slow to clear,
Each sufferer says his say, his scheme of the weal and woe:
But God has a few of us whom he whispers in the ear;
The rest may reason and welcome; ’tis we musicians know.

XII.

Well, it is earth with me; silence resumes her reign:


I will be patient and proud, and soberly acquiesce.
Give me the keys. I feel for the common chord again,
Sliding by semitones, till I sink to the minor,—yes,
And I blunt it into a ninth, and I stand on alien ground,
Surveying awhile the heights I rolled from into the deep
Which, hark, I have dared and done, for my resting-place is found,
The C major of this life: so, now I will try to sleep.

Having given specimen poems dealing with the arts of poetry,


painting, and sculpture, we add one on the subject of music, which,
though difficult to understand fully, has beauties which are apparent
even to those who do not enter into its deepest thought. Vogler is

You might also like