text: //
  //  NSData+Bitcoin.h
  //  BreadWallet
  //
  //  Created by Aaron Voisine on 10/9/13.
  //  Copyright (c) 2013 Aaron Voisine <voisine@gmail.com>
  //
  //  Permission is hereby granted, free of charge, to any person obtaining a copy
  //  of this software and associated documentation files (the "Software"), to deal
  //  in the Software without restriction, including without limitation the rights
  //  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  //  copies of the Software, and to permit persons to whom the Software is
  //  furnished to do so, subject to the following conditions:
  //
  //  The above copyright notice and this permission notice shall be included in
  //  all copies or substantial portions of the Software.
  //
  //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  //  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  //  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  //  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  //  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  //  THE SOFTWARE.
  
  #import <Foundation/Foundation.h>
  #import <CommonCrypto/CommonDigest.h>
  
  #define RMD160_DIGEST_LENGTH (160/8)
  #define X11_DIGEST_LENGTH 64
  
  #define VAR_INT16_HEADER 0xfd
  #define VAR_INT32_HEADER 0xfe
  #define VAR_INT64_HEADER 0xff
  
  // bitcoin script opcodes: https://en.bitcoin.it/wiki/Script#Constants
  #define OP_PUSHDATA1   0x4c
  #define OP_PUSHDATA2   0x4d
  #define OP_PUSHDATA4   0x4e
  #define OP_DUP         0x76
  #define OP_EQUAL       0x87
  #define OP_EQUALVERIFY 0x88
  #define OP_HASH160     0xa9
  #define OP_CHECKSIG    0xac
  
  @interface NSData (Bitcoin)
  
  - (NSData *)SHA1;
  - (NSData *)SHA256;
  - (NSData *)SHA256_2;
  - (NSData *)RMD160;
  - (NSData *)hash160;
  - (NSData *)hashX11;
  - (NSData *)reverse;
  
  - (uint8_t)UInt8AtOffset:(NSUInteger)offset;
  - (uint16_t)UInt16AtOffset:(NSUInteger)offset;
  - (uint32_t)UInt32AtOffset:(NSUInteger)offset;
  - (uint64_t)UInt64AtOffset:(NSUInteger)offset;
  - (uint64_t)varIntAtOffset:(NSUInteger)offset length:(NSUInteger *)length;
  - (NSData *)hashAtOffset:(NSUInteger)offset;
  - (NSString *)stringAtOffset:(NSUInteger)offset length:(NSUInteger *)length;
  - (NSData *)dataAtOffset:(NSUInteger)offset length:(NSUInteger *)length;
  
  - (NSArray *)scriptElements; // an array of NSNumber and NSData objects representing each script element
  - (int)intValue; // returns the opcode used to store the receiver in a script (i.e. OP_PUSHDATA1)
  
  @end
  