Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Ethereum Cookbook

You're reading from   Ethereum Cookbook Over 100 recipes covering Ethereum-based tokens, games, wallets, smart contracts, protocols, and Dapps

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789133998
Length 404 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Manoj P R Manoj P R
Author Profile Icon Manoj P R
Manoj P R
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
1. Getting Started FREE CHAPTER 2. Smart Contract Development 3. Interacting with the Contract 4. The Truffle Suite 5. Tokens and ICOs 6. Games and DAOs 7. Advanced Solidity 8. Smart Contract Security 9. Design Decisions 10. Other Protocols and Applications 11. Miscellaneous 1. Other Books You May Enjoy Index

Mathematical and cryptographic functions in solidity


Solidity provides a few inbuilt functions for performing mathematical and cryptographic operations. These functions can be used for a variety of tasks, including hash calculation and public key retrieval. 

In this recipe, you will learn to use some of the common functions in solidity for performing mathematical and cryptographic tasks.

Getting ready

You need to have a working Ethereum installation for deploying and testing the smart contract. You can also use the Remix IDE to write and test solidity code.

It is required to have a basic knowledge of solidity to understand this recipe. Go through Chapter 2Smart Contract Development, for more information.

How to do it...

  1. To calculate the SHA-3 (keccak-256) hash of something, use the keccak256/sha3 function:
keccak256(...)
// OR
sha3(...) // alias to keccak256
  1. The function returns the hash in bytes32 format:
keccak256(...) returns (bytes32);
  1. Since the arguments to this functions are concatenated without...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images