280
Appendix B: Software
end
end
if ˜exist(’G’,’var’) disp(’no y found’); return; end
ishow=1;
Pc=G; data(1,:)=G;
plot(G(1),G(2),’r*’,’MarkerSize’,10); hold on
for k=2:2*p
Pc=ECadd_p(Pc,G,a,b,p);
data(k,:)=Pc;
if Pc(2) == Inf
disp([’Order of group = ’,num2str(k)]); ishow=0;
end
if ishow==0, break; end
end
plot(data(2:end,1),data(2:end,2),’k.’,’MarkerSize’,10)
xlim([0,p]); ylim([0,p]); xlabel(’x’); ylabel(’y’)
Again, the reader is encouraged to explore different parameters xstart, but also
a, b, and p.
B.12 Ethereum Contract Test Environment
A test environment to develop Ethereum contracts comprises of the ganache
blockchain from https://www.trufflesuite.com/ganache, which comes as a single
binary file for most computer systems. Running the binary sets up a blockchain,
ready to be used. In order to interact with it, we need to install the MetaMask wallet
from https://metamask.io as an extension to a browser—Chrome is recommended.
After installing it, assigning passwords, and noting the security phrase in a safe place,
we choose the ganache blockchain and import one of the test accounts into MetaMask. This allows us to send Ethereum to other test accounts. Programming smart
contracts is most easily accomplished using the Remix online editor and compiler,
available from https://remix-project.org. Once it is loaded into the browser, we select
the solidity compiler, open a new file and start coding. All activities are accessible
from the menu on the far-left side of the browser window. The second item from the
top gives access to the source code of the contract, the third compiles the contract,
and the fourth is used to deploy it on a blockchain. Since deployment costs gas, we
have to connect the editor to our wallet, by changing “JavaScript VM” to “Injected
Web3” under “Environment.” After granting MetaMask the permission to interact
with the editor, we can press the “Deploy” button, which submits the contract to our
test blockchain. There is a basic interface to the contract at the bottom of the page
that also provides the address under which the contract is known on the blockchain.
With the contract deployed, we can directly send ether currency from our MetaMask wallet to the address of the contract, as described in Sect. 12.9.
Précédent

- 286/292

Suivant